Skip to content

Commit 49f03b4

Browse files
authored
ci: deployment workflow update (#63)
* rework deployment workflow * change name * small fixes
1 parent 28bdf0c commit 49f03b4

File tree

2 files changed

+224
-95
lines changed

2 files changed

+224
-95
lines changed

.github/workflows/deploy-wildcat-docker.yml

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

.github/workflows/deploy.yml

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
name: Deploy wildcat-dashboard-ui (Cloudflare Pages)
2+
3+
on:
4+
# auto deploy new tag to CF project PREVIEW
5+
push:
6+
tags:
7+
- 'v*'
8+
9+
# promote a version to CF project PRODUCTION
10+
workflow_dispatch:
11+
inputs:
12+
environment:
13+
description: 'target'
14+
required: true
15+
default: 'wildcat-dev-docker'
16+
type: choice
17+
options:
18+
- wildcat-dev-docker
19+
- wildcat-docker
20+
21+
env:
22+
NODE_VERSION: 22
23+
24+
25+
jobs:
26+
27+
######################################################################
28+
# ENV: wildcat-dev-docker
29+
# CF project: wildcat-dev-docker
30+
######################################################################
31+
deploy-wildcat-dev-docker:
32+
runs-on: ubuntu-latest
33+
permissions:
34+
contents: read
35+
deployments: write
36+
37+
# set env
38+
name: Deploy to ${{ vars.CLOUDFLARE_PROJECT_DEV_DOCKER }}
39+
40+
if: |
41+
github.event_name == 'push' ||
42+
(github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'wildcat-dev-docker')
43+
44+
env:
45+
PROJECT_NAME: ${{ vars.CLOUDFLARE_PROJECT_DEV_DOCKER }}
46+
VITE_API_BASE_URL: ${{ vars.VITE_API_BASE_URL_DEV_DOCKER }}
47+
VITE_KEYCLOAK_URL: ${{ vars.VITE_KEYCLOAK_URL_DEV_DOCKER }}
48+
VITE_KEYCLOAK_REALM: ${{ vars.VITE_KEYCLOAK_REALM_DEV_DOCKER || 'dev' }}
49+
VITE_KEYCLOAK_CLIENT_ID: ${{ vars.VITE_KEYCLOAK_CLIENT_ID_DEV_DOCKER || 'bff-dashboard' }}
50+
VITE_API_MOCKING_ENABLED: 'false'
51+
52+
# checkout, validate on dispatch, setup and build, deploy
53+
steps:
54+
- name: Checkout ${{ github.ref_name }}
55+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
56+
with:
57+
ref: ${{ github.ref }}
58+
fetch-depth: 0
59+
60+
- name: Validate tag on manual dispatch
61+
if: github.event_name == 'workflow_dispatch'
62+
run: |
63+
if [[ "${{ github.ref_type }}" != 'tag' ]]; then
64+
echo "::error::Manual deployments must be triggered from a tag."
65+
echo "::error::Please select a tag from the 'Use workflow from' dropdown, not a branch."
66+
exit 1
67+
fi
68+
echo "Validation successful: Running from tag '${{ github.ref_name }}'."
69+
70+
- name: Setup Node
71+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
72+
with:
73+
node-version: ${{ env.NODE_VERSION }}
74+
75+
- name: Cache node modules
76+
id: cache-npm
77+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
78+
env:
79+
cache-name: cache-node-modules
80+
with:
81+
path: ~/.npm
82+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
83+
restore-keys: |
84+
${{ runner.os }}-build-${{ env.cache-name }}-
85+
${{ runner.os }}-build-
86+
${{ runner.os }}-
87+
88+
- name: List the state of node modules
89+
if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
90+
continue-on-error: true
91+
run: npm list
92+
93+
- name: Install dependencies
94+
run: npm ci
95+
96+
- name: Build app
97+
run: npm run build
98+
99+
# PREVIEW branch
100+
- name: Deploy ${{ github.ref_name }} to PREVIEW branch of ${{ env.PROJECT_NAME }} project
101+
if: github.event_name == 'push'
102+
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1
103+
with:
104+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
105+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
106+
command: pages deploy dist --project-name=${{ env.PROJECT_NAME }} --branch=preview
107+
108+
# VERSION branch
109+
- name: Deploy ${{ github.ref_name }} to VERSION branch ${{ github.ref_name }} of ${{ env.PROJECT_NAME }} project
110+
if: github.event_name == 'push'
111+
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1
112+
with:
113+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
114+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
115+
command: pages deploy dist --project-name=${{ env.PROJECT_NAME }} --branch=${{ github.ref_name }}
116+
117+
# PRODUCTION branch
118+
- name: Deploy ${{ github.ref_name }} to PRODUCTION of ${{ env.PROJECT_NAME }} project
119+
if: github.event_name == 'workflow_dispatch'
120+
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1
121+
with:
122+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
123+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
124+
command: pages deploy dist --project-name=${{ env.PROJECT_NAME }}
125+
126+
127+
######################################################################
128+
# ENV: wildcat-docker
129+
# CF project: wildcat-docker
130+
######################################################################
131+
deploy-wildcat-docker:
132+
runs-on: ubuntu-latest
133+
permissions:
134+
contents: read
135+
deployments: write
136+
137+
# set env
138+
name: Deploy to ${{ vars.CLOUDFLARE_PROJECT_DOCKER }}
139+
140+
if: |
141+
github.event_name == 'push' ||
142+
(github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'wildcat-docker')
143+
144+
env:
145+
PROJECT_NAME: ${{ vars.CLOUDFLARE_PROJECT_DOCKER }}
146+
VITE_API_BASE_URL: ${{ vars.VITE_API_BASE_URL_DOCKER }}
147+
VITE_KEYCLOAK_URL: ${{ vars.VITE_KEYCLOAK_URL_DOCKER }}
148+
VITE_KEYCLOAK_REALM: ${{ vars.VITE_KEYCLOAK_REALM_DOCKER || 'dev' }}
149+
VITE_KEYCLOAK_CLIENT_ID: ${{ vars.VITE_KEYCLOAK_CLIENT_ID_DOCKER || 'bff-dashboard' }}
150+
VITE_API_MOCKING_ENABLED: 'false'
151+
152+
# checkout, validate on dispatch, setup and build, deploy
153+
steps:
154+
- name: Checkout ${{ github.ref_name }}
155+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
156+
with:
157+
ref: ${{ github.ref }}
158+
fetch-depth: 0
159+
160+
- name: Validate tag on manual dispatch
161+
if: github.event_name == 'workflow_dispatch'
162+
run: |
163+
if [[ "${{ github.ref_type }}" != 'tag' ]]; then
164+
echo "::error::Manual deployments must be triggered from a tag."
165+
echo "::error::Please select a tag from the 'Use workflow from' dropdown, not a branch."
166+
exit 1
167+
fi
168+
echo "Validation successful: Running from tag '${{ github.ref_name }}'."
169+
170+
- name: Setup Node
171+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
172+
with:
173+
node-version: ${{ env.NODE_VERSION }}
174+
175+
- name: Cache node modules
176+
id: cache-npm
177+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
178+
env:
179+
cache-name: cache-node-modules
180+
with:
181+
path: ~/.npm
182+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
183+
restore-keys: |
184+
${{ runner.os }}-build-${{ env.cache-name }}-
185+
${{ runner.os }}-build-
186+
${{ runner.os }}-
187+
188+
- name: List the state of node modules
189+
if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
190+
continue-on-error: true
191+
run: npm list
192+
193+
- name: Install dependencies
194+
run: npm ci
195+
196+
- name: Build app
197+
run: npm run build
198+
199+
# PREVIEW branch
200+
- name: Deploy ${{ github.ref_name }} to PREVIEW branch of ${{ env.PROJECT_NAME }} project
201+
if: github.event_name == 'push'
202+
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1
203+
with:
204+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
205+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
206+
command: pages deploy dist --project-name=${{ env.PROJECT_NAME }} --branch=preview
207+
208+
# VERSION branch
209+
- name: Deploy ${{ github.ref_name }} to VERSION branch ${{ github.ref_name }} of ${{ env.PROJECT_NAME }} project
210+
if: github.event_name == 'push'
211+
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1
212+
with:
213+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
214+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
215+
command: pages deploy dist --project-name=${{ env.PROJECT_NAME }} --branch=${{ github.ref_name }}
216+
217+
# PRODUCTION branch
218+
- name: Deploy ${{ github.ref_name }} to PRODUCTION of ${{ env.PROJECT_NAME }} project
219+
if: github.event_name == 'workflow_dispatch'
220+
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1
221+
with:
222+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
223+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
224+
command: pages deploy dist --project-name=${{ env.PROJECT_NAME }}

0 commit comments

Comments
 (0)