Skip to content

Deploy Docs

Deploy Docs #8466

Workflow file for this run

# 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'
runs-on: ubuntu-latest
steps:
- name: Check for docs artifact
id: check-artifact
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
retries: 3
script: |
try {
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id
});
const hasDocsArtifact = artifacts.data.artifacts.some(a => a.name === 'artifact-docs');
core.setOutput('has-docs', hasDocsArtifact);
} catch (error) {
console.error('Error checking for artifacts:', error);
core.setOutput('has-docs', false);
}
- name: Checkout code
if: ${{ steps.check-artifact.outputs.has-docs == 'true' }}
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download docs artifact
if: ${{ steps.check-artifact.outputs.has-docs == 'true' }}
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: artifact-docs
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
path: packages/docs
- name: Verify dist directory exists
if: ${{ steps.check-artifact.outputs.has-docs == 'true' }}
run: test -d packages/docs/dist
# not the official version, so be careful when updating
- name: Deploy to Cloudflare Pages
if: ${{ steps.check-artifact.outputs.has-docs == 'true' }}
uses: AdrianGonz97/refined-cf-pages-action@6c0d47ff7c97c48fa702b6d9f71f7e3a7c30c7d8
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: 'qwik-docs'
directory: packages/docs/dist
# v1 docs are production (qwik.dev); main (v2) stays the original qwikdev-build-v2 preview until launch
branch: ${{ github.event.workflow_run.event == 'pull_request' && format('pr-{0}', github.event.workflow_run.pull_requests[0].number) || (github.event.workflow_run.head_branch == 'v1' && 'main') || (github.event.workflow_run.head_branch == 'main' && 'qwikdev-build-v2') || format('preview-{0}', github.event.workflow_run.head_branch) }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Skip message when no docs artifact
if: ${{ steps.check-artifact.outputs.has-docs != 'true' }}
run: echo "No docs artifact found, skipping deployment"