Deploy docs preview #113
This file contains 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
# Use this starter workflow to deploy HTML generated by Antora to surge.sh | |
# Docs are published at <org>-<repo>-<deployid>.surge.sh | |
# By default, this workflow runs on completion of a workflow called "Verify PR" | |
# This workflow expects the triggering workflow to generate an artifact called "docs" | |
# - update the reference to "docs" and "docs.zip" in this workflow if your triggering workflow generates an artifact with a different name | |
name: "Deploy to surge" | |
on: | |
workflow_run: | |
workflows: ["Verify PR"] | |
types: | |
- completed | |
jobs: | |
publish-docs: | |
# if: github.event.workflow_run.conclusion == 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Download built documentation" | |
uses: actions/[email protected] | |
with: | |
script: | | |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{ github.event.workflow_run.id }}, | |
}); | |
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "docs" | |
})[0]; | |
var download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
var fs = require('fs'); | |
fs.writeFileSync('${{ github.workspace }}/docs.zip', Buffer.from(download.data)); | |
- run: unzip docs.zip | |
- id: get-deploy-id | |
run: | | |
deployid=$(<deployid) | |
echo "::set-output name=deploy-id::$deployid" | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: lts/* | |
- name: Deploy docs to surge | |
shell: bash | |
env: | |
SURGE_TOKEN: "${{ secrets.DOCS_SURGE_TOKEN }}" | |
run: | | |
npm install -g surge | |
surge ./site ${{ github.event.repository.owner.login}}-${{ github.event.repository.name}}-${{ steps.get-deploy-id.outputs.deploy-id }}.surge.sh --token "$SURGE_TOKEN" | |
- name: Comment on PR | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
number: ${{ steps.get-deploy-id.outputs.deploy-id }} | |
message: | | |
Looks like you've updated the documentation! | |
Check out your changes at https://${{ github.event.repository.owner.login}}-${{ github.event.repository.name}}-${{ steps.get-deploy-id.outputs.deploy-id }}.surge.sh | |
GITHUB_TOKEN: ${{ secrets.DOCS_PR_COMMENT_TOKEN }} |