diff --git a/.github/workflows/docs-deploy-surge.yml b/.github/workflows/docs-deploy-surge.yml index 7d3248b44..2399928e4 100644 --- a/.github/workflows/docs-deploy-surge.yml +++ b/.github/workflows/docs-deploy-surge.yml @@ -6,11 +6,13 @@ # 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 +# change to force workflow with no changelog + name: "Deploy docs preview" on: workflow_run: - workflows: ["Verify Docs PR"] + workflows: ["Verify docs PR"] types: - completed @@ -23,7 +25,7 @@ jobs: steps: - name: "Download built documentation" - uses: actions/github-script@v6.4.1 + uses: actions/github-script@v7 env: RUN_ID: ${{ github.event.workflow_run.id }} WORKSPACE: ${{ github.workspace }} @@ -34,19 +36,41 @@ jobs: repo: context.repo.repo, run_id: ${{ env.RUN_ID }}, }); - var matchArtifact = artifacts.data.artifacts.filter((artifact) => { + + var matchArtifactDocs = artifacts.data.artifacts.filter((artifact) => { return artifact.name == "docs" })[0]; - var download = await github.rest.actions.downloadArtifact({ + var downloadDocs = await github.rest.actions.downloadArtifact({ owner: context.repo.owner, repo: context.repo.repo, - artifact_id: matchArtifact.id, + artifact_id: matchArtifactDocs.id, archive_format: 'zip', }); var fs = require('fs'); - fs.writeFileSync('${{ env.WORKSPACE }}/docs.zip', Buffer.from(download.data)); - - - run: unzip docs.zip + fs.writeFileSync('${{ env.WORKSPACE }}/docs.zip', Buffer.from(downloadDocs.data)); + + var matchArtifactChangelog = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "changelog" + })[0]; + var downloadChangelog = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifactChangelog.id, + archive_format: 'zip', + }); + fs.writeFileSync('${{ env.WORKSPACE }}/changelog.zip', Buffer.from(downloadChangelog.data)); + + - id: unzip-docs + run: unzip docs.zip + + - id: get-top-dir + run: | + root=$(ls -d */index.html | sed -r 's/(.*)\/index\.html/\1/') + echo "top-dir=$root" >> $GITHUB_OUTPUT + + - id: unzip-changelog + if: ${{ hashFiles('changelog.zip') != '' }} + run: unzip changelog.zip - id: get-deploy-id run: | @@ -63,7 +87,7 @@ jobs: deployurl=$ORG-$REPO-$DEPLOYID.surge.sh echo "deploy-url=$deployurl" >> $GITHUB_OUTPUT - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: lts/* @@ -72,15 +96,16 @@ jobs: env: DEPLOY_URL: ${{ steps.get-deploy-url.outputs.deploy-url }} SURGE_TOKEN: "${{ secrets.DOCS_SURGE_TOKEN }}" + SITE_DIR: ${{ steps.get-top-dir.outputs.top-dir }} run: | npm install -g surge - surge ./site $DEPLOY_URL --token "$SURGE_TOKEN" + surge ./$SITE_DIR $DEPLOY_URL --token "$SURGE_TOKEN" # If the PR artifacts include a changelog file, add it to the PR as a comment # The changelog contains links to new and changed files in the deployed docs - name: Comment on PR (changelog) if: ${{ hashFiles('changelog') != '' }} - uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd #v2.8.0 + uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 #v2.9.0 with: number: ${{ steps.get-deploy-id.outputs.deploy-id }} recreate: true @@ -93,7 +118,7 @@ jobs: if: ${{ hashFiles('changelog') == '' }} env: DEPLOY_URL: ${{ steps.get-deploy-url.outputs.deploy-url }} - uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd #v2.8.0 + uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 #v2.9.0 with: number: ${{ steps.get-deploy-id.outputs.deploy-id }} header: docs-pr-changes diff --git a/.github/workflows/docs-pr-checks.yml b/.github/workflows/docs-pr-checks.yml index ec4640239..07965cd90 100644 --- a/.github/workflows/docs-pr-checks.yml +++ b/.github/workflows/docs-pr-checks.yml @@ -9,11 +9,12 @@ on: - "4.[0-9]" - "3.5" + jobs: # Generate HTML docs-build-pr: - uses: neo4j/docs-tools/.github/workflows/reusable-docs-build.yml@v1.0.3 + uses: neo4j/docs-tools/.github/workflows/reusable-docs-build.yml@v1.1.2 with: deploy-id: ${{ github.event.number }} retain-artifacts: 14 @@ -23,7 +24,7 @@ jobs: # By default, the job fails if there are errors, passes if there are warnings only. docs-verify-pr: needs: docs-build-pr - uses: neo4j/docs-tools/.github/workflows/reusable-docs-verify.yml@v1.0.3 + uses: neo4j/docs-tools/.github/workflows/reusable-docs-verify.yml@v1.1.2 with: failOnWarnings: true @@ -55,7 +56,7 @@ jobs: docs-updates-comment-pr: if: needs.docs-build-pr.outputs.pages-listed == 'success' needs: [docs-build-pr, docs-changes-pr] - uses: neo4j/docs-tools/.github/workflows/reusable-docs-pr-changes.yml@v1.0.3 + uses: neo4j/docs-tools/.github/workflows/reusable-docs-pr-changes.yml@v1.1.2 with: pages-modified: ${{ needs.docs-changes-pr.outputs.pages-modified }} pages-added: ${{ needs.docs-changes-pr.outputs.pages-added }} diff --git a/.github/workflows/docs-teardown.yml b/.github/workflows/docs-teardown.yml index 9ab7f8774..e2dcc782c 100644 --- a/.github/workflows/docs-teardown.yml +++ b/.github/workflows/docs-teardown.yml @@ -39,7 +39,7 @@ jobs: surge teardown $DEPLOY_URL --token "$SURGE_TOKEN" - name: Comment on PR - uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # v2.8.0 + uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0 with: number: ${{ github.event.pull_request.number }} header: docs-pr-changes @@ -48,3 +48,4 @@ jobs: The preview documentation has now been torn down - reopening this PR will republish it. GITHUB_TOKEN: ${{ secrets.DOCS_PR_COMMENT_TOKEN }} +