Skip to content

Deploy docs preview #1527

Deploy docs preview

Deploy docs preview #1527

# 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)
case "$deployid" in ''|*[!0-9]*) echo "Provided PR number is not an integer"; exit 1 ;; esac
echo "deploy-id=$deployid" >> "$GITHUB_OUTPUT"
- 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: |
This PR includes documentation updates.
You can view the updated docs 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 }}