Skip to content

Commit 2eb0575

Browse files
Add GHA
1 parent 227ace6 commit 2eb0575

File tree

3 files changed

+122
-0
lines changed

3 files changed

+122
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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 }}

.github/workflows/docs-pr.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Use this starter workflow to verify PRs that include a change to the docs
2+
# The default setup runs against PRs targeting your default branch
3+
# Default artifact retention is 7 days
4+
5+
name: "Verify PR"
6+
7+
on:
8+
pull_request:
9+
branches:
10+
- "4.4"
11+
- "5.0"
12+
- "5.x"
13+
- "dev"
14+
15+
jobs:
16+
17+
# note that the build job requires a build-verify script in package.json
18+
# build-verify should build html with Antora, and output a .json log file
19+
# eg 'antora playbook.yml --log-format=json --log-file ./build/log/log.json'
20+
docs-build-for-pr:
21+
uses: recrwplay/actions-demo/.github/workflows/reusable-docs-build.yml@main
22+
with:
23+
deploy-id: ${{ github.event.number }}
24+
retain-artifacts: 14
25+
26+
docs-verify-for-pr:
27+
needs: docs-build-for-pr
28+
uses: recrwplay/actions-demo/.github/workflows/reusable-docs-verify.yml@main
29+
with:
30+
failOnWarnings: true
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# copy this workflow into your repo
2+
name: "Documentation Teardown"
3+
4+
on:
5+
pull_request_target:
6+
branches:
7+
- "4.4"
8+
- "5.0"
9+
- "5.x"
10+
- "dev"
11+
types:
12+
- closed
13+
14+
jobs:
15+
teardown-docs:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/setup-node@v3
20+
with:
21+
node-version: lts/*
22+
- name: Teardown documentation
23+
run: |
24+
npm install -g surge
25+
surge teardown ${{ github.event.repository.owner.login}}-${{ github.event.repository.name}}-${{ github.event.pull_request.number }}.surge.sh --token ${{ secrets.SURGE_TOKEN }}

0 commit comments

Comments
 (0)