|
| 1 | +# Use this starter workflow to deploy HTML generated by Antora to surge.sh |
| 2 | +# Docs are published at <org>-<repo>-<deployid>.surge.sh |
| 3 | +# By default, this workflow runs on completion of a workflow called "Verify PR" |
| 4 | +# This workflow expects the triggering workflow to generate an artifact called "docs" |
| 5 | + |
| 6 | +# - update the reference to "docs" and "docs.zip" in this workflow if your triggering workflow generates an artifact with a different name |
| 7 | +name: "Deploy to surge" |
| 8 | + |
| 9 | +on: |
| 10 | + workflow_run: |
| 11 | + workflows: ["Verify PR"] |
| 12 | + types: |
| 13 | + - completed |
| 14 | + |
| 15 | +jobs: |
| 16 | + publish-docs: |
| 17 | + # if: github.event.workflow_run.conclusion == 'success' |
| 18 | + |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: "Download built documentation" |
| 23 | + uses: actions/github-script@v6.0.0 |
| 24 | + with: |
| 25 | + script: | |
| 26 | + var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ |
| 27 | + owner: context.repo.owner, |
| 28 | + repo: context.repo.repo, |
| 29 | + run_id: ${{ github.event.workflow_run.id }}, |
| 30 | + }); |
| 31 | + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { |
| 32 | + return artifact.name == "docs" |
| 33 | + })[0]; |
| 34 | + var download = await github.rest.actions.downloadArtifact({ |
| 35 | + owner: context.repo.owner, |
| 36 | + repo: context.repo.repo, |
| 37 | + artifact_id: matchArtifact.id, |
| 38 | + archive_format: 'zip', |
| 39 | + }); |
| 40 | + var fs = require('fs'); |
| 41 | + fs.writeFileSync('${{ github.workspace }}/docs.zip', Buffer.from(download.data)); |
| 42 | + |
| 43 | + - run: unzip docs.zip |
| 44 | + |
| 45 | + - id: get-deploy-id |
| 46 | + run: | |
| 47 | + deployid=$(<deployid) |
| 48 | + echo "::set-output name=deploy-id::$deployid" |
| 49 | + |
| 50 | + - uses: actions/setup-node@v3 |
| 51 | + with: |
| 52 | + node-version: lts/* |
| 53 | + |
| 54 | + - name: Deploy docs to surge |
| 55 | + run: | |
| 56 | + npm install -g surge |
| 57 | + surge ./site ${{ github.event.repository.owner.login}}-${{ github.event.repository.name}}-${{ steps.get-deploy-id.outputs.deploy-id }}.surge.sh --token ${{ secrets.SURGE_TOKEN }} |
| 58 | +
|
| 59 | + - name: Comment on PR |
| 60 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 61 | + with: |
| 62 | + number: ${{ steps.get-deploy-id.outputs.deploy-id }} |
| 63 | + message: | |
| 64 | + Looks like you've updated the documentation! |
| 65 | +
|
| 66 | + Check out your changes at https://${{ github.event.repository.owner.login}}-${{ github.event.repository.name}}-${{ steps.get-deploy-id.outputs.deploy-id }}.surge.sh |
| 67 | + GITHUB_TOKEN: ${{ secrets.DOCS_PR_COMMENT_TOKEN }} |
0 commit comments