Skip to content

Commit 1313765

Browse files
committed
New workflows (#1322)
1 parent 0fa2538 commit 1313765

File tree

5 files changed

+170
-43
lines changed

5 files changed

+170
-43
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This is an example of the docs-pr.yml workflow available from the recrwplay org
2+
name: "Verify Branch"
3+
4+
on:
5+
# push:
6+
# branches:
7+
# - main
8+
# - dev
9+
# schedule:
10+
# - cron: '00 16 * * *'
11+
workflow_dispatch:
12+
inputs:
13+
html:
14+
description: 'Generate HTML'
15+
type: boolean
16+
required: false
17+
default: true
18+
links:
19+
description: 'Check links'
20+
type: boolean
21+
required: false
22+
default: true
23+
lint:
24+
description: 'Lint docs'
25+
type: boolean
26+
required: false
27+
default: false
28+
29+
jobs:
30+
31+
docs-build:
32+
if: ${{ inputs.html || github.event_name == 'push' }}
33+
name: Generate HTML
34+
uses: neo4j/docs-tools/.github/workflows/reusable-docs-build.yml@dev
35+
with:
36+
retain-artifacts: 14
37+
deploy-id: 0
38+
39+
docs-verify:
40+
name: Verify HTML
41+
needs: docs-build
42+
uses: neo4j/docs-tools/.github/workflows/reusable-docs-verify.yml@dev
43+
44+
docs-links:
45+
if: ${{ inputs.links || github.event_name == 'push' }}
46+
name: Check links
47+
needs: docs-build
48+
uses: neo4j/docs-tools/.github/workflows/reusable-docs-links.yml@dev
49+
50+
docs-lint:
51+
if: ${{ inputs.lint || github.event_name == 'push' }}
52+
name: Lint docs
53+
uses: neo4j/docs-tools/.github/workflows/reusable-docs-vale.yml@dev
54+
Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
# Use this starter workflow to deploy HTML generated by Antora to surge.sh
22
# Docs are published at <org>-<repo>-<deployid>.surge.sh
3-
# By default, this workflow runs on completion of a workflow called "Verify PR"
3+
#
4+
# By default, this workflow runs on completion of a workflow called "Verify docs PR"
5+
#
46
# This workflow expects the triggering workflow to generate an artifact called "docs"
5-
67
# - update the reference to "docs" and "docs.zip" in this workflow if your triggering workflow generates an artifact with a different name
7-
name: "Deploy to surge"
8+
9+
name: "Deploy docs preview"
810

911
on:
1012
workflow_run:
11-
workflows: ["Verify PR"]
13+
workflows: ["Verify docs PR"]
1214
types:
1315
- completed
1416

1517
jobs:
1618
publish-docs:
19+
# Uncomment this if statement to deploy only when the PR builds cleanly
1720
# if: github.event.workflow_run.conclusion == 'success'
1821

1922
runs-on: ubuntu-latest
2023

2124
steps:
2225
- name: "Download built documentation"
23-
uses: actions/[email protected]
26+
uses: actions/[email protected]
27+
env:
28+
RUN_ID: ${{ github.event.workflow_run.id }}
29+
WORKSPACE: ${{ github.workspace }}
2430
with:
2531
script: |
2632
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
2733
owner: context.repo.owner,
2834
repo: context.repo.repo,
29-
run_id: ${{ github.event.workflow_run.id }},
35+
run_id: ${{ env.RUN_ID }},
3036
});
3137
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
3238
return artifact.name == "docs"
@@ -38,7 +44,7 @@ jobs:
3844
archive_format: 'zip',
3945
});
4046
var fs = require('fs');
41-
fs.writeFileSync('${{ github.workspace }}/docs.zip', Buffer.from(download.data));
47+
fs.writeFileSync('${{ env.WORKSPACE }}/docs.zip', Buffer.from(download.data));
4248
4349
- run: unzip docs.zip
4450

@@ -47,6 +53,15 @@ jobs:
4753
deployid=$(<deployid)
4854
case "$deployid" in ''|*[!0-9]*) echo "Provided PR number is not an integer"; exit 1 ;; esac
4955
echo "deploy-id=$deployid" >> "$GITHUB_OUTPUT"
56+
57+
- id: get-deploy-url
58+
env:
59+
ORG: ${{ github.event.repository.owner.login }}
60+
REPO: ${{ github.event.repository.name }}
61+
DEPLOYID: ${{ steps.get-deploy-id.outputs.deploy-id }}
62+
run: |
63+
deployurl=$ORG-$REPO-$DEPLOYID.surge.sh
64+
echo "deploy-url=$deployurl" >> $GITHUB_OUTPUT
5065
5166
- uses: actions/setup-node@v3
5267
with:
@@ -55,17 +70,35 @@ jobs:
5570
- name: Deploy docs to surge
5671
shell: bash
5772
env:
73+
DEPLOY_URL: ${{ steps.get-deploy-url.outputs.deploy-url }}
5874
SURGE_TOKEN: "${{ secrets.DOCS_SURGE_TOKEN }}"
5975
run: |
6076
npm install -g surge
61-
surge ./site ${{ github.event.repository.owner.login}}-${{ github.event.repository.name}}-${{ steps.get-deploy-id.outputs.deploy-id }}.surge.sh --token "$SURGE_TOKEN"
77+
surge ./site $DEPLOY_URL --token "$SURGE_TOKEN"
6278
63-
- name: Comment on PR
79+
# If the PR artifacts include a changelog file, add it to the PR as a comment
80+
# The changelog contains links to new and changed files in the deployed docs
81+
- name: Comment on PR (changelog)
82+
if: ${{ hashFiles('changelog') != '' }}
83+
uses: marocchino/sticky-pull-request-comment@v2
84+
with:
85+
number: ${{ steps.get-deploy-id.outputs.deploy-id }}
86+
recreate: true
87+
header: docs-pr-changes
88+
path: changelog
89+
GITHUB_TOKEN: ${{ secrets.DOCS_PR_COMMENT_TOKEN }}
90+
91+
# If there's no changelog, add a generic comment to the PR
92+
- name: Comment on PR (no changelog)
93+
if: ${{ hashFiles('changelog') == '' }}
94+
env:
95+
DEPLOY_URL: ${{ steps.get-deploy-url.outputs.deploy-url }}
6496
uses: marocchino/sticky-pull-request-comment@v2
6597
with:
6698
number: ${{ steps.get-deploy-id.outputs.deploy-id }}
99+
header: docs-pr-changes
67100
message: |
68-
This PR includes documentation updates.
101+
Looks like you've updated the documentation!
69102
70-
You can view the updated docs at https://${{ github.event.repository.owner.login}}-${{ github.event.repository.name}}-${{ steps.get-deploy-id.outputs.deploy-id }}.surge.sh
103+
Check out your changes at https://${{ env.DEPLOY_URL }}
71104
GITHUB_TOKEN: ${{ secrets.DOCS_PR_COMMENT_TOKEN }}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
name: "Verify docs PR"
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- dev
8+
9+
jobs:
10+
11+
# Generate HTML
12+
docs-build-pr:
13+
uses: neo4j/docs-tools/.github/workflows/reusable-docs-build.yml@main
14+
with:
15+
deploy-id: ${{ github.event.number }}
16+
retain-artifacts: 14
17+
18+
# Parse the json log output from the HTML build, and output warnings and errors as annotations
19+
# Optionally, fail the build if there are warnings or errors
20+
# By default, the job fails if there are errors, passes if there are warnings only.
21+
docs-verify-pr:
22+
needs: docs-build-pr
23+
uses: neo4j/docs-tools/.github/workflows/reusable-docs-verify.yml@main
24+
with:
25+
failOnWarnings: true
26+
27+
# Get lists of changes in the PR
28+
# - all updated asciidoc files
29+
# - all updated asciidoc pages
30+
# - all new asciidoc pages
31+
docs-changes-pr:
32+
runs-on: ubuntu-latest
33+
outputs:
34+
asciidoc-files: ${{ steps.get-file-changes.outputs.asciidoc_all_changed_files }}
35+
pages-modified: ${{ steps.get-file-changes.outputs.pages_modified_files }}
36+
pages-added: ${{ steps.get-file-changes.outputs.pages_added_files }}
37+
steps:
38+
- name: Get file changes
39+
id: get-file-changes
40+
uses: tj-actions/changed-files@v41
41+
with:
42+
separator: ','
43+
files_yaml: |
44+
pages:
45+
- modules/**/pages/**/*.adoc
46+
asciidoc:
47+
- modules/**/*.adoc
48+
49+
# Generate a PR comment if the docs are using the pageList extension
50+
# The extension maps asciidoc source files to their HTML output paths
51+
# The comment will contain links to new and changed pages in the deployed HTML docs
52+
docs-updates-comment-pr:
53+
if: needs.docs-build-pr.outputs.pages-listed == 'success'
54+
needs: [docs-build-pr, docs-changes-pr]
55+
uses: neo4j/docs-tools/.github/workflows/reusable-docs-pr-changes.yml@main
56+
with:
57+
pages-modified: ${{ needs.docs-changes-pr.outputs.pages-modified }}
58+
pages-added: ${{ needs.docs-changes-pr.outputs.pages-added }}

.github/workflows/docs-pr.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/docs-teardown.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name: "Documentation Teardown"
33

44
on:
55
pull_request_target:
6-
branches:
7-
- "4.[0-9]"
8-
- "5.x"
9-
- "dev"
106
types:
117
- closed
128

@@ -18,17 +14,30 @@ jobs:
1814
- uses: actions/setup-node@v3
1915
with:
2016
node-version: lts/*
17+
18+
- id: get-deploy-url
19+
env:
20+
ORG: ${{ github.event.repository.owner.login }}
21+
REPO: ${{ github.event.repository.name }}
22+
DEPLOYID: ${{ github.event.pull_request.number }}
23+
run: |
24+
deployurl=$ORG-$REPO-$DEPLOYID.surge.sh
25+
echo "deploy-url=$deployurl" >> $GITHUB_OUTPUT
26+
2127
- name: Teardown documentation
2228
shell: bash
2329
env:
2430
SURGE_TOKEN: "${{ secrets.DOCS_SURGE_TOKEN }}"
31+
DEPLOY_URL: ${{ steps.get-deploy-url.outputs.deploy-url }}
2532
run: |
2633
npm install -g surge
27-
surge teardown ${{ github.event.repository.owner.login}}-${{ github.event.repository.name}}-${{ github.event.pull_request.number }}.surge.sh --token "$SURGE_TOKEN"
34+
surge teardown $DEPLOY_URL --token "$SURGE_TOKEN"
35+
2836
- name: Comment on PR
2937
uses: marocchino/sticky-pull-request-comment@v2
3038
with:
3139
number: ${{ github.event.pull_request.number }}
40+
header: docs-pr-changes
3241
message: |
3342
Thanks for the documentation updates.
3443

0 commit comments

Comments
 (0)