Skip to content

Commit

Permalink
chore(ci): move docs deploy to separate flow (#6762)
Browse files Browse the repository at this point in the history
* chore(ci):  move docs deploy to separate flow

this allows PR branches to also get docs previews

* Update .github/workflows/deploy-docs.yml

Co-authored-by: Giorgio Boa <[email protected]>

---------

Co-authored-by: Giorgio Boa <[email protected]>
  • Loading branch information
wmertens and gioboa authored Aug 5, 2024
1 parent 2571e1e commit 59c2c43
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 43 deletions.
49 changes: 6 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ jobs:
uses: actions/cache/restore@v4
with:
lookup-only: true
path: |
packages/docs/dist
packages/docs/server
path: docs-build-completed.txt
key: ${{ hashfiles('others-key.txt', 'packages/docs/**/*') }}
- name: 'check cache: insights'
id: cache-insights
Expand Down Expand Up @@ -578,7 +576,7 @@ jobs:
- run: corepack pnpm install --frozen-lockfile
- name: Build Qwik Docs
run: pnpm run build.packages.docs
run: pnpm run build.packages.docs && echo ok > docs-build-completed.txt

- name: Save Docs Artifacts
uses: actions/upload-artifact@v4
Expand All @@ -592,44 +590,7 @@ jobs:
uses: actions/cache/save@v4
with:
key: ${{ needs.changes.outputs.hash-docs }}
path: |
packages/docs/dist
packages/docs/server
# TODO: move this to a run_workflow action that has repository permissions and grabs the artifact
deploy-docs:
name: Cloudflare Pages Deployment
if: always() && needs.changes.outputs.build-docs == 'true'
needs:
- build-docs
- changes
runs-on: ubuntu-latest

steps:
- name: Check docs status
if: needs.build-docs.result != 'success'
run: exit 1

- name: Checkout
uses: actions/checkout@v4

- name: Restore docs cache
uses: actions/cache/restore@v4
with:
key: ${{ needs.changes.outputs.hash-docs }}
path: |
packages/docs/dist
packages/docs/server
# not the official version, so be careful when updating
- name: Deploy to Cloudflare Pages
uses: AdrianGonz97/refined-cf-pages-action@c7b767eef599f127d8ce2388d4ed2270d3b750af
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: 'qwik-docs'
directory: packages/docs/dist
githubToken: ${{ secrets.GITHUB_TOKEN }}
path: docs-build-completed.txt

############ UNIT TEST ############
test-unit:
Expand Down Expand Up @@ -792,8 +753,10 @@ jobs:
- test-e2e
# test-unit runs when any packages changes, so we have to release
# on main, we always check if we have something to release
# don't run on forks
if: |
always() && (
always() &&
github.repository == 'QwikDev/qwik' && (
github.ref == 'refs/heads/main' ||
needs.test-unit.result == 'success'
)
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# a workflow that runs after the "Qwik CI" workflow is successful
# and deploys the documentation to CloudFlare Pages.

name: Deploy Docs

on:
workflow_run:
workflows: ['Qwik CI']
types:
- completed

permissions:
actions: read
deployments: write
contents: read
pull-requests: write

jobs:
deploy:
name: Cloudflare Pages Deployment
if: >
github.repository == 'QwikDev/qwik' &&
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Download docs artifact
continue-on-error: true
uses: actions/download-artifact@v4
id: download-artifact
with:
name: artifact-docs
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
path: |
packages/docs/dist
packages/docs/server
# not the official version, so be careful when updating
- name: Deploy to Cloudflare Pages
# if the docs didn't build, don't deploy but don't fail the workflow
if: success()
uses: AdrianGonz97/refined-cf-pages-action@11cfce77186cf1bd43f2fe42a84ea1996bcfe3c9
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: 'qwik-docs'
directory: packages/docs/dist
githubToken: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 59c2c43

Please sign in to comment.