66# This workflow expects the triggering workflow to generate an artifact called "docs"
77# - update the reference to "docs" and "docs.zip" in this workflow if your triggering workflow generates an artifact with a different name
88
9+ # change to force workflow with no changelog
10+
911name : " Deploy docs preview"
1012
1113on :
1214 workflow_run :
13- workflows : ["Verify Docs PR"]
15+ workflows : ["Verify docs PR"]
1416 types :
1517 - completed
1618
2325
2426 steps :
2527 - name : " Download built documentation"
26- uses : actions/github-script@v6.4.1
28+ uses : actions/github-script@v7
2729 env :
2830 RUN_ID : ${{ github.event.workflow_run.id }}
2931 WORKSPACE : ${{ github.workspace }}
@@ -34,19 +36,41 @@ jobs:
3436 repo: context.repo.repo,
3537 run_id: ${{ env.RUN_ID }},
3638 });
37- var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
39+
40+ var matchArtifactDocs = artifacts.data.artifacts.filter((artifact) => {
3841 return artifact.name == "docs"
3942 })[0];
40- var download = await github.rest.actions.downloadArtifact({
43+ var downloadDocs = await github.rest.actions.downloadArtifact({
4144 owner: context.repo.owner,
4245 repo: context.repo.repo,
43- artifact_id: matchArtifact .id,
46+ artifact_id: matchArtifactDocs .id,
4447 archive_format: 'zip',
4548 });
4649 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
5074
5175 - id : get-deploy-id
5276 run : |
6387 deployurl=$ORG-$REPO-$DEPLOYID.surge.sh
6488 echo "deploy-url=$deployurl" >> $GITHUB_OUTPUT
6589
66- - uses : actions/setup-node@v3
90+ - uses : actions/setup-node@v4
6791 with :
6892 node-version : lts/*
6993
@@ -72,15 +96,16 @@ jobs:
7296 env :
7397 DEPLOY_URL : ${{ steps.get-deploy-url.outputs.deploy-url }}
7498 SURGE_TOKEN : " ${{ secrets.DOCS_SURGE_TOKEN }}"
99+ SITE_DIR : ${{ steps.get-top-dir.outputs.top-dir }}
75100 run : |
76101 npm install -g surge
77- surge ./site $DEPLOY_URL --token "$SURGE_TOKEN"
102+ surge ./$SITE_DIR $DEPLOY_URL --token "$SURGE_TOKEN"
78103
79104 # If the PR artifacts include a changelog file, add it to the PR as a comment
80105 # The changelog contains links to new and changed files in the deployed docs
81106 - name : Comment on PR (changelog)
82107 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
84109 with :
85110 number : ${{ steps.get-deploy-id.outputs.deploy-id }}
86111 recreate : true
93118 if : ${{ hashFiles('changelog') == '' }}
94119 env :
95120 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
97122 with :
98123 number : ${{ steps.get-deploy-id.outputs.deploy-id }}
99124 header : docs-pr-changes
0 commit comments