Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 40 additions & 16 deletions .github/workflows/docs-deploy-surge.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Use this starter workflow to deploy HTML generated by Antora to surge.sh
# Docs are published at <org>-<repo>-<deployid>.surge.sh

# By default, this workflow runs on completion of a workflow called "Verify PR"

#
# By default, this workflow runs on completion of a workflow called "Verify docs PR"
#
# 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 All @@ -102,4 +127,3 @@ jobs:

Check out your changes at https://${{ env.DEPLOY_URL }}
GITHUB_TOKEN: ${{ secrets.DOCS_PR_COMMENT_TOKEN }}

14 changes: 7 additions & 7 deletions .github/workflows/docs-pr-checks.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@

name: "Verify Docs PR"
name: "Verify docs PR"

on:
pull_request:
branches:
- "main"
- "dev"
- "5.x"
- "4.[0-9]"
- "3.5"
- "4.4"

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 +23,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 +55,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 }}
pages-added: ${{ needs.docs-changes-pr.outputs.pages-added }}
10 changes: 5 additions & 5 deletions .github/workflows/docs-teardown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ name: "Documentation Teardown"
on:
pull_request_target:
branches:
- "main"
- "dev"
- "5.x"
- "4.[0-9]"
- "3.5"
- "4.4"
types:
- closed

Expand All @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: lts/*

Expand All @@ -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,4 +48,4 @@ jobs:

The preview documentation has now been torn down - reopening this PR will republish it.
GITHUB_TOKEN: ${{ secrets.DOCS_PR_COMMENT_TOKEN }}

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ target/

# docs project
.env
package-lock.json
node_modules/
worktrees/
*/modules/api/
Loading