Generate Docs #170
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate Docs | |
| on: | |
| workflow_dispatch: | |
| workflow_call: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: 'generate-documentation' | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: fusion-gh-runner-fusion-framework | |
| outputs: | |
| preview-path: ${{ steps.preview-path.outputs.value }} | |
| is-preview: ${{ steps.mode.outputs.value }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup fusion runner | |
| continue-on-error: true | |
| uses: ./.github/actions/setup-fusion-runner | |
| # single source of truth for preview-vs-production, reused by every step below and by deploy | |
| - name: Determine preview mode | |
| id: mode | |
| shell: bash | |
| run: echo "value=${{ github.ref != 'refs/heads/main' }}" >> "$GITHUB_OUTPUT" | |
| - name: Determine preview path | |
| if: ${{ steps.mode.outputs.value == 'true' }} | |
| id: preview-path | |
| shell: bash | |
| run: echo "value=$(printf '%s' "$GITHUB_REF_NAME" | sed 's#[^A-Za-z0-9._-]#-#g')" >> "$GITHUB_OUTPUT" | |
| - name: Build documentation | |
| if: ${{ steps.mode.outputs.value == 'false' }} | |
| uses: ./.github/actions/build-docs | |
| - name: Build preview | |
| if: ${{ steps.mode.outputs.value == 'true' }} | |
| uses: ./.github/actions/build-docs | |
| env: | |
| VUEPRESS_BASE: /fusion-framework/previews/${{ steps.preview-path.outputs.value }}/ | |
| with: | |
| upload-artifact: false | |
| - name: Preserve preview output | |
| if: ${{ steps.mode.outputs.value == 'true' }} | |
| shell: bash | |
| run: | | |
| mkdir -p "$RUNNER_TEMP/docs-preview" | |
| cp -R vue-press/dist/. "$RUNNER_TEMP/docs-preview/" | |
| - name: Checkout main | |
| if: ${{ steps.mode.outputs.value == 'true' }} | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Build production documentation | |
| if: ${{ steps.mode.outputs.value == 'true' }} | |
| uses: ./.github/actions/build-docs | |
| with: | |
| upload-artifact: false | |
| - name: Add preview to production output | |
| if: ${{ steps.mode.outputs.value == 'true' }} | |
| shell: bash | |
| run: | | |
| mkdir -p "vue-press/dist/previews/${{ steps.preview-path.outputs.value }}" | |
| cp -R "$RUNNER_TEMP/docs-preview/." "vue-press/dist/previews/${{ steps.preview-path.outputs.value }}/" | |
| - name: Upload Pages artifact | |
| if: ${{ steps.mode.outputs.value == 'true' }} | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: ./vue-press/dist | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ needs.build.outputs.is-preview == 'true' && format('{0}previews/{1}/', steps.deployment.outputs.page_url, needs.build.outputs.preview-path) || steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 | |
| - name: Publish preview URL | |
| if: ${{ needs.build.outputs.is-preview == 'true' }} | |
| shell: bash | |
| run: echo "### [Open docs preview](${{ steps.deployment.outputs.page_url }}previews/${{ needs.build.outputs.preview-path }}/)" >> "$GITHUB_STEP_SUMMARY" |