Skip to content

Commit 40a301e

Browse files
authored
add workflow for tagged versions (#60)
1 parent 785e163 commit 40a301e

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Deploy to wildcat-docker (Cloudflare Pages)
2+
3+
on:
4+
# 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-docker
19+
- wildcat-dev-docker
20+
21+
jobs:
22+
deploy:
23+
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
deployments: write
28+
29+
# define environments
30+
strategy:
31+
matrix:
32+
include:
33+
- environment: 'wildcat-dev-docker'
34+
project_name: ${{ secrets.CLOUDFLARE_PROJECT_DEV_DOCKER }}
35+
vite_api_base_url: ${{ vars.VITE_API_BASE_URL_DEV_DOCKER }}
36+
vite_keycloak_url: ${{ vars.VITE_KEYCLOAK_URL_DEV_DOCKER }}
37+
vite_keycloak_realm: 'dev'
38+
vite_keycloak_client_id: 'bff-dashboard'
39+
- environment: 'wildcat-docker'
40+
project_name: ${{ secrets.CLOUDFLARE_PROJECT_DOCKER }}
41+
vite_api_base_url: ${{ vars.VITE_API_BASE_URL_DOCKER }}
42+
vite_keycloak_url: ${{ vars.VITE_KEYCLOAK_URL_DOCKER }}
43+
vite_keycloak_realm: 'dev'
44+
vite_keycloak_client_id: 'bff-dashboard'
45+
46+
# only run job for the selected environment on manual dispatch or on push to a tag
47+
if: |
48+
github.event_name == 'push' ||
49+
(github.event_name == 'workflow_dispatch' && github.event.inputs.environment == matrix.environment)
50+
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
with:
55+
ref: ${{ github.ref }}
56+
fetch-depth: 0
57+
58+
# only allow tags on manual dispatch
59+
- name: Validate Tag on Manual Dispatch
60+
if: github.event_name == 'workflow_dispatch'
61+
run: |
62+
if [[ "${{ github.ref_type }}" != 'tag' ]]; then
63+
echo "::error::Manual deployments must be triggered from a tag."
64+
echo "::error::Please select a tag from the 'Use workflow from' dropdown, not a branch."
65+
exit 1
66+
fi
67+
echo "✅ Validation successful: Running from tag '${{ github.ref_name }}'."
68+
69+
- name: Setup Node.js
70+
uses: actions/setup-node@v4
71+
with:
72+
node-version: 22
73+
74+
- name: Install dependencies
75+
run: npm ci
76+
77+
- name: Build application for ${{ matrix.environment }}
78+
run: npm run build
79+
env:
80+
VITE_API_BASE_URL: ${{ matrix.vite_api_base_url }}
81+
VITE_KEYCLOAK_URL: ${{ matrix.vite_keycloak_url }}
82+
VITE_KEYCLOAK_REALM: ${{ matrix.vite_keycloak_realm }}
83+
VITE_KEYCLOAK_CLIENT_ID: ${{ matrix.vite_keycloak_client_id }}
84+
VITE_API_MOCKING_ENABLED: false
85+
86+
- name: Deploy ${{ matrix.environment }} to Cloudflare Pages (PREVIEW)
87+
id: deploy_preview
88+
if: github.event_name == 'push'
89+
uses: cloudflare/wrangler-action@v3
90+
with:
91+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
92+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
93+
command: pages deploy dist --project-name=${{ matrix.project_name }} --branch=preview
94+
95+
- name: Deploy ${{ matrix.environment }} to Cloudflare Pages (PRODUCTION)
96+
id: deploy_production
97+
if: github.event_name == 'workflow_dispatch'
98+
uses: cloudflare/wrangler-action@v3
99+
with:
100+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
101+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
102+
# Target the production branch ('main' or 'master') for manual deployments
103+
command: pages deploy dist --project-name=${{ matrix.project_name }} --branch=master

0 commit comments

Comments
 (0)