-
Notifications
You must be signed in to change notification settings - Fork 11
71 lines (60 loc) · 2.69 KB
/
docs-deploy-surge.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# 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 }}