diff --git a/.github/workflows/docs-deploy-surge.yml b/.github/workflows/docs-deploy-surge.yml index 7d3248b..2399928 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 5680a16..59a03a2 100644 --- a/.github/workflows/docs-pr-checks.yml +++ b/.github/workflows/docs-pr-checks.yml @@ -1,17 +1,16 @@ -name: "Verify Docs PR" +name: "Verify docs PR" on: pull_request: branches: - main - - dev 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.2.0 with: deploy-id: ${{ github.event.number }} retain-artifacts: 14 @@ -21,7 +20,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.2.0 with: failOnWarnings: true @@ -53,7 +52,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.2.0 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 5453693..41398c3 100644 --- a/.github/workflows/docs-teardown.yml +++ b/.github/workflows/docs-teardown.yml @@ -5,7 +5,6 @@ on: pull_request_target: branches: - main - - dev types: - closed @@ -14,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: lts/* @@ -37,7 +36,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 @@ -46,3 +45,4 @@ jobs: The preview documentation has now been torn down - reopening this PR will republish it. GITHUB_TOKEN: ${{ secrets.DOCS_PR_COMMENT_TOKEN }} +