Skip to content

Commit

Permalink
Use latest workflows (#918)
Browse files Browse the repository at this point in the history
  • Loading branch information
recrwplay committed Mar 8, 2024
1 parent c205629 commit d6b490a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 16 deletions.
49 changes: 37 additions & 12 deletions .github/workflows/docs-deploy-surge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 }}
Expand All @@ -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: |
Expand All @@ -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/*

Expand All @@ -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
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/docs-pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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 }}
3 changes: 2 additions & 1 deletion .github/workflows/docs-teardown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}

0 comments on commit d6b490a

Please sign in to comment.