Skip to content

Commit 8e90568

Browse files
committed
pdf build workflows
1 parent 7481fdc commit 8e90568

16 files changed

+11336
-241
lines changed

.github/workflows/build-pages.yml

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Build pages
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
ref:
6+
description: Ref name to build
7+
required: true
8+
type: string
9+
sha:
10+
description: SHA, should correspond to ref
11+
required: true
12+
type: string
13+
workflow_call:
14+
inputs:
15+
ref:
16+
description: Ref name to build
17+
required: true
18+
type: string
19+
sha:
20+
description: SHA, should correspond to ref
21+
required: true
22+
type: string
23+
24+
jobs:
25+
build:
26+
runs-on: docs-16c-64gb-600gb
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
ref: ${{ inputs.sha }}
31+
fetch-depth: 0 # fetch whole repo so git-restore-mtime can work
32+
lfs: true
33+
34+
- name: Adjust file watchers limit
35+
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
36+
37+
- uses: actions/setup-node@v4
38+
with:
39+
node-version-file: ".nvmrc"
40+
cache: "npm"
41+
cache-dependency-path: "package-lock.json"
42+
env:
43+
NODE_ENV: ${{ secrets.NODE_ENV }}
44+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
46+
- name: Install dependencies
47+
run: |
48+
npm run presetup
49+
npm ci --ignore-scripts
50+
env:
51+
NODE_ENV: ${{ secrets.NODE_ENV }}
52+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
53+
54+
- name: Run NPM install scripts
55+
run: |
56+
npm rebuild
57+
58+
- name: Checking Gatsby cache
59+
id: gatsby-cache-build
60+
uses: actions/cache@v4
61+
with:
62+
path: |
63+
public/*
64+
!public/pdfs
65+
.cache
66+
key: ${{ runner.os }}-gatsby-build-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-${{ inputs.ref }}-${{ inputs.sha }}
67+
restore-keys: |
68+
${{ runner.os }}-gatsby-build-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-${{ inputs.ref }}
69+
${{ runner.os }}-gatsby-build-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}
70+
${{ runner.os }}-gatsby-build
71+
72+
- name: Fix mtimes
73+
run: npm run fix-mtimes
74+
75+
- name: Gatsby build
76+
run: npm run build
77+
env:
78+
APP_ENV: staging
79+
NODE_ENV: ${{ vars.NODE_ENV }}
80+
NODE_OPTIONS: --max-old-space-size=4096
81+
FATHOM_SITE_ID: ${{ vars.FATHOM_SITE_ID }}
82+
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
83+
ALGOLIA_SEARCH_ONLY_KEY: ${{ vars.ALGOLIA_SEARCH_ONLY_KEY }}
84+
ALGOLIA_APP_ID: ${{ vars.ALGOLIA_APP_ID }}
85+
ALGOLIA_INDEX_NAME: edb-docs-staging
86+
INDEX_ON_BUILD: ${{ inputs.ref == 'develop' }}
87+
88+
- name: Store pages
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: pages-build
92+
path: |
93+
public/*
94+
!public/pdfs

.github/workflows/build-pdfs.yml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Generate PDFs
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
ref:
6+
description: Ref name to build
7+
required: true
8+
type: string
9+
sha:
10+
description: SHA, should correspond to ref
11+
required: true
12+
type: string
13+
workflow_call:
14+
inputs:
15+
ref:
16+
description: Ref name to build
17+
required: true
18+
type: string
19+
sha:
20+
description: SHA, should correspond to ref
21+
required: true
22+
type: string
23+
24+
jobs:
25+
build:
26+
runs-on: docs-16c-64gb-600gb
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
ref: ${{ inputs.sha }}
31+
lfs: true
32+
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version-file: ".nvmrc"
36+
cache: "npm"
37+
cache-dependency-path: "package-lock.json"
38+
env:
39+
NODE_ENV: ${{ vars.NODE_ENV }}
40+
41+
- uses: actions/setup-python@v5
42+
with:
43+
python-version: "3.11.6"
44+
45+
- uses: r-lib/actions/setup-pandoc@v2
46+
with:
47+
pandoc-version: "2.14.1"
48+
49+
- name: Install wkhtmltopdf
50+
run: |
51+
curl -L https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.jammy_amd64.deb > wkhtmltopdf.deb
52+
sudo apt update
53+
sudo apt install -y ./wkhtmltopdf.deb
54+
sudo apt install -y rsync
55+
56+
- name: Install Python dependencies
57+
run: pip install -r requirements-ci.txt
58+
59+
- name: Install PDF Node dependencies
60+
working-directory: ./scripts/pdf
61+
run: |
62+
npm install
63+
64+
- name: Checking PDF cache
65+
id: pdf-cache-build
66+
uses: actions/cache@v4
67+
with:
68+
path: |
69+
product_docs/**/*.pdf
70+
product_docs/**/*.pdf-hash
71+
advocacy_docs/**/*.pdf
72+
advocacy_docs/**/*.pdf-hash
73+
key: ${{ runner.os }}-build-pdfs-${{ hashFiles('scripts/pdf/*', 'scripts/pdf/lib/*') }}-${{ inputs.sha }}
74+
restore-keys: |
75+
${{ runner.os }}-build-pdfs-${{ hashFiles('scripts/pdf/*', 'scripts/pdf/lib/*') }}
76+
77+
- name: Build all pdfs
78+
run: npm run pdf:build-all-ci
79+
80+
- name: Copy pdfs to build output
81+
run: |
82+
mkdir -p public/pdfs
83+
shopt -s globstar
84+
rsync -avm --filter="+ */" --filter="-! *.pdf" advocacy_docs/ public/pdfs/
85+
rsync -avm --filter="+ */" --filter="-! *.pdf" product_docs/docs/ public/pdfs/
86+
87+
- name: Store pdfs
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: pdf-build
91+
path: public/*

.github/workflows/deploy-draft.yml

+41-81
Original file line numberDiff line numberDiff line change
@@ -9,90 +9,50 @@ concurrency:
99
cancel-in-progress: true
1010

1111
jobs:
12-
build-deploy:
12+
build-pages:
1313
if: |
1414
(
1515
(github.event.action == 'labeled' && github.event.label.name == 'deploy') ||
16-
(github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'deploy'))
16+
(contains(github.event.pull_request.labels.*.name, 'deploy'))
1717
) && !github.event.pull_request.head.repo.fork
18-
runs-on: docs-16c-64gb-600gb
19-
steps:
20-
- name: inject slug/short variables
21-
uses: rlespinasse/github-slug-action@v4
22-
23-
- name: compose a name for the build environment
24-
run: echo "BUILD_ENV_NAME=pr-${{ github.event.number }}-${{ env.GITHUB_HEAD_REF_SLUG }}" >> $GITHUB_ENV
25-
26-
- uses: actions/checkout@v4
27-
with:
28-
ref: ${{ github.event.pull_request.head.sha }}
29-
fetch-depth: 0 # fetch whole repo so git-restore-mtime can work
30-
lfs: true
31-
32-
- name: Adjust file watchers limit
33-
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
34-
35-
- uses: actions/setup-node@v4
36-
with:
37-
node-version-file: ".nvmrc"
38-
cache: "npm"
39-
cache-dependency-path: "package-lock.json"
40-
env:
41-
NODE_ENV: ${{ secrets.NODE_ENV }}
42-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
43-
44-
- name: Install dependencies
45-
run: |
46-
npm run presetup
47-
npm ci --ignore-scripts
48-
env:
49-
NODE_ENV: ${{ secrets.NODE_ENV }}
50-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
18+
uses: ./.github/workflows/build-pages.yml
19+
with:
20+
ref: ${{ github.head_ref }}
21+
sha: ${{ github.event.pull_request.head.sha }}
22+
secrets: inherit
5123

52-
- name: Run NPM install scripts
24+
build-pdfs:
25+
if: |
26+
(
27+
(github.event.action == 'labeled' && github.event.label.name == 'deploy-pdfs') ||
28+
(contains(github.event.pull_request.labels.*.name, 'deploy-pdfs'))
29+
) && !github.event.pull_request.head.repo.fork
30+
uses: ./.github/workflows/build-pdfs.yml
31+
with:
32+
ref: ${{ github.head_ref }}
33+
sha: ${{ github.event.pull_request.head.sha }}
34+
35+
# this serves to allow building PDFs to be optional without preventing deployment,
36+
# while still failing the workflow if we *try* to build PDFs and fail
37+
# there are ways to do this in conditions on a single job, but this keeps things clear
38+
# this job will fail only if build-pdfs failed (not if it was skipped)
39+
# however, it will set an output - check-has-pdfs.steps.check.has-pdfs - true if PDFs were generated
40+
check-has-pdfs:
41+
needs: build-pdfs
42+
if: ${{ always() }}
43+
runs-on: ubuntu-22.04
44+
steps:
45+
- name: check
5346
run: |
54-
npm rebuild
55-
56-
- name: Checking Gatsby cache
57-
id: gatsby-cache-build
58-
uses: actions/cache@v4
59-
with:
60-
path: |
61-
public/*
62-
!public/pdfs
63-
.cache
64-
key: ${{ runner.os }}-gatsby-build-draft-${{ github.head_ref }}-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}-${{ github.sha }}
65-
restore-keys: |
66-
${{ runner.os }}-gatsby-build-draft-${{ github.head_ref }}
67-
${{ runner.os }}-gatsby-build-develop-${{ hashFiles('package.json', 'gatsby-config.js', 'gatsby-node.js') }}
68-
${{ runner.os }}-gatsby-build-develop
69-
70-
- name: Fix mtimes
71-
run: npm run fix-mtimes
72-
73-
- name: Gatsby build
74-
run: npm run build
75-
env:
76-
APP_ENV: staging
77-
NODE_ENV: ${{ vars.NODE_ENV }}
78-
NODE_OPTIONS: --max-old-space-size=4096
79-
FATHOM_SITE_ID: ${{ vars.FATHOM_SITE_ID }}
80-
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
81-
ALGOLIA_SEARCH_ONLY_KEY: ${{ vars.ALGOLIA_SEARCH_ONLY_KEY }}
82-
ALGOLIA_APP_ID: ${{ vars.ALGOLIA_APP_ID }}
83-
ALGOLIA_INDEX_NAME: edb-docs-staging
84-
INDEX_ON_BUILD: false
85-
86-
- name: Deploy to Netlify
87-
id: netlify-deploy
88-
uses: nwtgck/actions-netlify@v3
89-
with:
90-
publish-dir: "./public"
91-
github-token: ${{ secrets.GITHUB_TOKEN }}
92-
deploy-message: ${{ github.event.pull_request.title }}
93-
enable-commit-comment: false
94-
github-deployment-environment: ${{ env.BUILD_ENV_NAME }}
95-
alias: deploy-preview-${{ github.event.number }}
96-
env:
97-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
98-
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DEVELOP_SITE_ID }}
47+
echo "has-pdfs=${{ needs.build-pdfs.result == 'success' }}" >> "$GITHUB_OUTPUT"
48+
exit ${{ needs.build-pdfs.result == 'failure' && 1 || 0 }}
49+
50+
deploy-to-netlify:
51+
needs: [build-pages, check-has-pdfs]
52+
# succeeded() (the default check) will be false at this point if PDFs were skipped
53+
if: ${{ !cancelled() && needs.build-pages.result == 'success' && needs.check-has-pdfs.result == 'success' }}
54+
uses: ./.github/workflows/deploy-to-netlify.yml
55+
with:
56+
enable-commit-comment: false
57+
alias: deploy-preview-${{ github.event.number }}
58+
secrets: inherit
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Deploy build to Netlify
2+
on:
3+
workflow_dispatch:
4+
workflow_call:
5+
inputs:
6+
enable-pull-request-comment:
7+
description: whether to comment on the triggering PR
8+
required: false
9+
default: true
10+
type: boolean
11+
enable-commit-comment:
12+
description: whether to comment on the triggering commit
13+
required: false
14+
default: true
15+
type: boolean
16+
alias:
17+
description: name for the deployment (used to set custom / stable Netlify url)
18+
required: false
19+
type: string
20+
21+
jobs:
22+
deploy:
23+
runs-on: ubuntu-22.04
24+
steps:
25+
- name: Pull build artifacts
26+
uses: actions/download-artifact@v4
27+
with:
28+
path: ./public
29+
merge-multiple: true
30+
31+
- name: list
32+
run: ls -lfR ./public
33+
34+
- name: Deploy to Netlify
35+
id: netlify-deploy
36+
uses: nwtgck/actions-netlify@v3
37+
with:
38+
publish-dir: "./public"
39+
github-token: ${{ secrets.GITHUB_TOKEN }}
40+
enable-pull-request-comment: ${{ inputs.enable-pull-request-comment }}
41+
enable-commit-comment: ${{ inputs.enable-commit-comment }}
42+
alias: ${{ inputs.alias }}
43+
env:
44+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
45+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DEVELOP_SITE_ID }}

.github/workflows/sync-and-process-files.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ jobs:
6767
- name: setup node
6868
uses: actions/setup-node@v4
6969
with:
70-
node-version: "18"
71-
72-
- name: update npm
73-
run: npm install -g npm@10
70+
node-version-file: "destination/.nvmrc"
7471

7572
- name: Process changes
7673
id: changes

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ These instructions are for members of the EnterpriseDB Github Org only. The icon
120120

121121
- If you already have a different version of Node installed, you may want to consider using Node Version Manager (NVM) for a simpler way to manage multiple versions of Node.js. Follow the [directions to install NVM](https://github.com/nvm-sh/nvm#installing-and-updating), then run `nvm install` in the cloned repo directory, followed by `nvm use` which will auto-detect the correct version of Node.js to use (currently 20 LTS).
122122

123-
1. Install Python 3 with `brew install python3`, if it's not already installed. (Use `python3 -V` to check that you have version 3.8 or higher.) Python is not needed for the core Gatsby system, but is required by several source scripts.
123+
1. Install Python 3 with `brew install python3`, if it's not already installed. (Use `python3 -V` to check that you have version 3.11 or higher.) Python is not needed for the core Gatsby system, but is required by several source scripts.
124124

125125
1. NPM 10 is the package manager we're using for this project.
126126

0 commit comments

Comments
 (0)