-
Notifications
You must be signed in to change notification settings - Fork 3
74 lines (70 loc) · 2.51 KB
/
trigger-website-fe-build.yml
File metadata and controls
74 lines (70 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Trigger website frontend build
on:
push:
branches: [dev]
paths:
- 'wiki/**'
release:
types: [published]
workflow_dispatch:
inputs:
stage:
description: "Target stage to dispatch"
required: true
type: choice
options:
- dev
- prod
default: dev
force_rebuild:
description: "Force full rebuild in target workflow"
required: false
type: boolean
default: false
env:
TARGET_OWNER: 42core-team
TARGET_REPO: website
TARGET_WORKFLOW_FILE: frontend-build.yml
jobs:
dispatch-dev:
name: Dispatch DEV deploy
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/dev') ||
(github.event_name == 'workflow_dispatch' && inputs.stage == 'dev')
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- name: Call workflow_dispatch in website (dev)
uses: actions/github-script@v8
with:
github-token: ${{ secrets.WSR_PAT }}
script: |
const isManual = context.eventName === 'workflow_dispatch';
const forceRebuild = isManual ? (context.payload.inputs.force_rebuild === true ? 'true' : 'false') : 'true'; // inputs as strings
await github.rest.actions.createWorkflowDispatch({
owner: process.env.TARGET_OWNER,
repo: process.env.TARGET_REPO,
workflow_id: process.env.TARGET_WORKFLOW_FILE,
ref: 'dev',
inputs: { environment: 'dev', force_rebuild: forceRebuild }
});
dispatch-prod:
name: Dispatch PROD deploy
if: |
(github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'workflow_dispatch' && inputs.stage == 'prod')
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- name: Call workflow_dispatch in website (prod)
uses: actions/github-script@v8
with:
github-token: ${{ secrets.WSR_PAT }}
script: |
const isManual = context.eventName === 'workflow_dispatch';
const forceRebuild = isManual ? (context.payload.inputs.force_rebuild === true ? 'true' : 'false') : 'true'; // inputs as strings
await github.rest.actions.createWorkflowDispatch({
owner: process.env.TARGET_OWNER,
repo: process.env.TARGET_REPO,
workflow_id: process.env.TARGET_WORKFLOW_FILE,
ref: 'main',
inputs: { environment: 'prod', force_rebuild: forceRebuild }
});