6
6
# This workflow expects the triggering workflow to generate an artifact called "docs"
7
7
# - update the reference to "docs" and "docs.zip" in this workflow if your triggering workflow generates an artifact with a different name
8
8
9
+ # change to force workflow with no changelog
10
+
9
11
name : " Deploy docs preview"
10
12
11
13
on :
12
14
workflow_run :
13
- workflows : ["Verify Docs PR"]
15
+ workflows : ["Verify docs PR"]
14
16
types :
15
17
- completed
16
18
23
25
24
26
steps :
25
27
- name : " Download built documentation"
26
- uses : actions/github-script@v6.4.1
28
+ uses : actions/github-script@v7
27
29
env :
28
30
RUN_ID : ${{ github.event.workflow_run.id }}
29
31
WORKSPACE : ${{ github.workspace }}
@@ -34,19 +36,41 @@ jobs:
34
36
repo: context.repo.repo,
35
37
run_id: ${{ env.RUN_ID }},
36
38
});
37
- var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
39
+
40
+ var matchArtifactDocs = artifacts.data.artifacts.filter((artifact) => {
38
41
return artifact.name == "docs"
39
42
})[0];
40
- var download = await github.rest.actions.downloadArtifact({
43
+ var downloadDocs = await github.rest.actions.downloadArtifact({
41
44
owner: context.repo.owner,
42
45
repo: context.repo.repo,
43
- artifact_id: matchArtifact .id,
46
+ artifact_id: matchArtifactDocs .id,
44
47
archive_format: 'zip',
45
48
});
46
49
var fs = require('fs');
47
- fs.writeFileSync('${{ env.WORKSPACE }}/docs.zip', Buffer.from(download.data));
48
-
49
- - run : unzip docs.zip
50
+ fs.writeFileSync('${{ env.WORKSPACE }}/docs.zip', Buffer.from(downloadDocs.data));
51
+
52
+ var matchArtifactChangelog = artifacts.data.artifacts.filter((artifact) => {
53
+ return artifact.name == "changelog"
54
+ })[0];
55
+ var downloadChangelog = await github.rest.actions.downloadArtifact({
56
+ owner: context.repo.owner,
57
+ repo: context.repo.repo,
58
+ artifact_id: matchArtifactChangelog.id,
59
+ archive_format: 'zip',
60
+ });
61
+ fs.writeFileSync('${{ env.WORKSPACE }}/changelog.zip', Buffer.from(downloadChangelog.data));
62
+
63
+ - id : unzip-docs
64
+ run : unzip docs.zip
65
+
66
+ - id : get-top-dir
67
+ run : |
68
+ root=$(ls -d */index.html | sed -r 's/(.*)\/index\.html/\1/')
69
+ echo "top-dir=$root" >> $GITHUB_OUTPUT
70
+
71
+ - id : unzip-changelog
72
+ if : ${{ hashFiles('changelog.zip') != '' }}
73
+ run : unzip changelog.zip
50
74
51
75
- id : get-deploy-id
52
76
run : |
63
87
deployurl=$ORG-$REPO-$DEPLOYID.surge.sh
64
88
echo "deploy-url=$deployurl" >> $GITHUB_OUTPUT
65
89
66
- - uses : actions/setup-node@v3
90
+ - uses : actions/setup-node@v4
67
91
with :
68
92
node-version : lts/*
69
93
@@ -72,15 +96,16 @@ jobs:
72
96
env :
73
97
DEPLOY_URL : ${{ steps.get-deploy-url.outputs.deploy-url }}
74
98
SURGE_TOKEN : " ${{ secrets.DOCS_SURGE_TOKEN }}"
99
+ SITE_DIR : ${{ steps.get-top-dir.outputs.top-dir }}
75
100
run : |
76
101
npm install -g surge
77
- surge ./site $DEPLOY_URL --token "$SURGE_TOKEN"
102
+ surge ./$SITE_DIR $DEPLOY_URL --token "$SURGE_TOKEN"
78
103
79
104
# If the PR artifacts include a changelog file, add it to the PR as a comment
80
105
# The changelog contains links to new and changed files in the deployed docs
81
106
- name : Comment on PR (changelog)
82
107
if : ${{ hashFiles('changelog') != '' }}
83
- uses : marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # v2.8 .0
108
+ uses : marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9 .0
84
109
with :
85
110
number : ${{ steps.get-deploy-id.outputs.deploy-id }}
86
111
recreate : true
93
118
if : ${{ hashFiles('changelog') == '' }}
94
119
env :
95
120
DEPLOY_URL : ${{ steps.get-deploy-url.outputs.deploy-url }}
96
- uses : marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # v2.8 .0
121
+ uses : marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9 .0
97
122
with :
98
123
number : ${{ steps.get-deploy-id.outputs.deploy-id }}
99
124
header : docs-pr-changes
0 commit comments