4
4
push :
5
5
branches :
6
6
- 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
7
14
8
15
jobs :
9
16
docs :
10
17
runs-on : buildjet-4vcpu-ubuntu-2204
18
+ env :
19
+ DEPLOY_REF : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || 'stable' }}
11
20
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
13
39
- uses : actions/checkout@v3
40
+ with :
41
+ ref : ${{ env.DEPLOY_REF }}
42
+
14
43
- uses : actions/setup-node@v3
15
44
with :
16
45
node-version : 20
17
46
check-latest : true
18
47
cache : yarn
48
+
19
49
- name : Node.js version
20
50
id : node
21
51
run : echo "v8CppApiVersion=$(node --print "process.versions.modules")" >> $GITHUB_OUTPUT
52
+
22
53
- name : Restore dependencies
23
54
uses : actions/cache@master
24
55
id : cache-deps
@@ -27,13 +58,14 @@ jobs:
27
58
node_modules
28
59
packages/*/node_modules
29
60
key : ${{ runner.os }}-${{ steps.node.outputs.v8CppApiVersion }}-${{ hashFiles('**/yarn.lock', '**/package.json') }}
61
+
30
62
- name : Install & build
31
63
if : steps.cache-deps.outputs.cache-hit != 'true'
32
64
run : yarn install --frozen-lockfile && yarn build
65
+
33
66
- name : Build
34
67
run : yarn build
35
68
if : steps.cache-deps.outputs.cache-hit == 'true'
36
- # </common-build>
37
69
38
70
- name : Build and collect docs
39
71
run : yarn build:docs
0 commit comments