Skip to content

Commit dc64cbf

Browse files
authored
Merge ee7032e into 61cf1a8
2 parents 61cf1a8 + ee7032e commit dc64cbf

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

.github/workflows/docs.yml

+34-2
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,52 @@ on:
44
push:
55
branches:
66
- stable
7+
workflow_dispatch:
8+
inputs:
9+
ref:
10+
description: 'Ref to deploy, defaults to `unstable`'
11+
required: false
12+
default: 'unstable'
13+
type: string
714

815
jobs:
916
docs:
1017
runs-on: buildjet-4vcpu-ubuntu-2204
18+
env:
19+
DEPLOY_REF: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || 'stable' }}
1120
steps:
12-
# <common-build> - Uses YAML anchors in the future
21+
# Validation step for workflow_dispatch ref input
22+
- name: Validate Ref
23+
if: github.event_name == 'workflow_dispatch'
24+
run: |
25+
if git rev-parse "${{ env.DEPLOY_REF }}" >/dev/null 2>&1; then
26+
echo "Ref ${{ env.DEPLOY_REF }} is valid."
27+
else
28+
echo "Error: Ref ${{ env.DEPLOY_REF }} is not a valid branch, tag or commit." >&2
29+
exit 1
30+
fi
31+
32+
# Log out the ref being deployed
33+
- name: Log Deployment Ref
34+
if: github.event_name == 'workflow_dispatch'
35+
run: |
36+
echo "Deploying ref: $DEPLOY_REF"
37+
38+
# Checkout the correct ref being deployed
1339
- uses: actions/checkout@v3
40+
with:
41+
ref: ${{ env.DEPLOY_REF }}
42+
1443
- uses: actions/setup-node@v3
1544
with:
1645
node-version: 20
1746
check-latest: true
1847
cache: yarn
48+
1949
- name: Node.js version
2050
id: node
2151
run: echo "v8CppApiVersion=$(node --print "process.versions.modules")" >> $GITHUB_OUTPUT
52+
2253
- name: Restore dependencies
2354
uses: actions/cache@master
2455
id: cache-deps
@@ -27,13 +58,14 @@ jobs:
2758
node_modules
2859
packages/*/node_modules
2960
key: ${{ runner.os }}-${{ steps.node.outputs.v8CppApiVersion }}-${{ hashFiles('**/yarn.lock', '**/package.json') }}
61+
3062
- name: Install & build
3163
if: steps.cache-deps.outputs.cache-hit != 'true'
3264
run: yarn install --frozen-lockfile && yarn build
65+
3366
- name: Build
3467
run: yarn build
3568
if: steps.cache-deps.outputs.cache-hit == 'true'
36-
# </common-build>
3769

3870
- name: Build and collect docs
3971
run: yarn build:docs

0 commit comments

Comments
 (0)