Skip to content

Commit e063ed2

Browse files
authored
Merge pull request #700 from DataIntegrationGroup/ci/cd-production-on-release-published
ci: trigger CD (Production) on release publish
2 parents f446557 + 7e88172 commit e063ed2

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

.github/workflows/CD_production.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11
name: CD (Production)
22

33
on:
4-
push:
5-
tags:
6-
- 'v*.*.*' # GA releases: v1.0.0, v1.4.2
7-
- 'v*.*.*-*' # SemVer pre-releases: v1.0.0-rc.1
8-
- 'v*.*.*[a-z]*' # PEP 440 pre-releases: v1.0.0rc1, v1.0.0b2 (release-please-python form)
4+
release:
5+
types: [published]
96

107
permissions:
118
contents: read
129

1310
jobs:
1411
production-deploy:
1512

13+
# Safety rail: only deploy when the release tag is version-shaped
14+
# (v*.*.*, v*.*.*-*, v*.*.*[a-z]*). startsWith() is a cheap pre-filter;
15+
# the "Validate release tag" step enforces the strict regex.
16+
if: startsWith(github.event.release.tag_name, 'v')
17+
1618
runs-on: ubuntu-latest
1719
environment: production
1820

1921
steps:
22+
- name: Validate release tag matches version pattern
23+
env:
24+
TAG: ${{ github.event.release.tag_name }}
25+
run: |
26+
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+|[a-z].*)?$ ]]; then
27+
echo "Release tag '$TAG' does not match the v*.*.* pattern. Refusing to deploy."
28+
exit 1
29+
fi
30+
2031
- name: Check out source repository
2132
uses: actions/checkout@v6.0.3
2233
with:
2334
fetch-depth: 0
35+
# Fully-qualified tag ref avoids ambiguity if a branch is ever
36+
# created with the same name as the release tag.
37+
ref: refs/tags/${{ github.event.release.tag_name }}
2438

2539
- name: Install uv in container
2640
uses: astral-sh/setup-uv@v8.2.0
@@ -69,7 +83,7 @@ jobs:
6983
7084
- name: Render App Engine configs
7185
env:
72-
APP_VERSION: ${{ github.ref_name }}
86+
APP_VERSION: ${{ github.event.release.tag_name }}
7387
ENVIRONMENT: "production"
7488
CLOUD_SQL_INSTANCE_NAME: "${{ secrets.CLOUD_SQL_INSTANCE_NAME }}"
7589
CLOUD_SQL_DATABASE: "${{ vars.CLOUD_SQL_DATABASE }}"

0 commit comments

Comments
 (0)