Skip to content

Commit 51a48b6

Browse files
authored
Merge branch 'dev' into update-semantic
2 parents f1271eb + d90cb54 commit 51a48b6

10 files changed

Lines changed: 111 additions & 286 deletions

File tree

.github/workflows/actionlint.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
name: Lint GitHub Workflows
2+
3+
permissions:
4+
contents: read
5+
actions: read
6+
27
on:
38
pull_request:
49
paths:
510
- ".github/workflows/**/*.yml"
611
- ".github/workflows/**/*.yaml"
12+
713
push:
814
paths:
915
- ".github/workflows/**/*.yml"
1016
- ".github/workflows/**/*.yaml"
17+
1118
jobs:
1219
actionlint:
13-
name: actionlint
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Checkout code
17-
uses: actions/checkout@v4
18-
- name: Lint workflow files
19-
uses: reviewdog/action-actionlint@v1
20+
uses: HDRUK/github-actions-templates/.github/workflows/actionlint.yaml@main

.github/workflows/deployment.yaml

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,59 +13,17 @@ on:
1313
- preprod
1414
- prod
1515
tag_version:
16-
description: 'Tag version to be deployed'
16+
description: 'Tag version to deploy'
1717
required: true
1818
default: ''
1919

20-
env:
21-
PROJECT_ID: "${{ secrets.PROJECT_ID }}"
22-
GAR_LOCATION: "${{ secrets.GAR_LOCATION }}"
23-
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL}}"
24-
SLACK_CHANNEL: "${{ secrets.GITHUBACTIONS_SLACK_CHANNEL }}"
25-
2620
jobs:
2721
deploy:
28-
permissions:
29-
contents: write
30-
id-token: write
31-
32-
runs-on: ubuntu-latest
33-
environment: ${{ github.event.inputs.env }}
34-
steps:
35-
- name: Checkout
36-
id: checkout
37-
uses: actions/checkout@v6
38-
with:
39-
ref: main
40-
41-
- name: Google Auth
42-
id: auth
43-
uses: "google-github-actions/auth@v2"
44-
with:
45-
token_format: "access_token"
46-
project_id: "${{ secrets.PROJECT_ID }}"
47-
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
48-
service_account: "${{ secrets.WIF_SERVICE_ACCOUNT }}"
49-
50-
- name: Deploy to Cloud Run
51-
uses: actions-hub/gcloud@540.0.0
52-
id: deploy
53-
env:
54-
PROJECT_ID: ${{ secrets.PROJECT_ID }}
55-
PROD_PROJECT_ID: ${{ secrets.PROD_PROJECT_ID }}
56-
GAR_LOCATION: ${{ secrets.GAR_LOCATION }}
57-
GAR_NAME: ${{ secrets.GAR_NAME }}
58-
SERVICE_NAME: "${{ secrets.SERVICE_NAME }}"
59-
SERVICE_REGION: "${{ secrets.SERVICE_REGION }}"
60-
with:
61-
args: run services update '${{ env.SERVICE_NAME }}' --image='${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROD_PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ github.event.inputs.tag_version }}:latest --region='${{ env.SERVICE_REGION }}' --project='${{ env.PROJECT_ID }}'
62-
63-
- name: Run Notification
64-
id: runnotificationsent
65-
uses: act10ns/slack@v1
66-
with:
67-
status: ${{ job.status }}
68-
steps: ${{ toJson(steps) }}
69-
channel: ${{ env.SLACK_CHANNEL }}
70-
message: Deploying tag ${{ github.event.inputs.tag_version }} to ENV ${{ github.event.inputs.env }} ${{ job.status }}
71-
if: always()
22+
uses: HDRUK/github-actions-templates/.github/workflows/deploy-release.yml@main
23+
with:
24+
env: ${{ github.event.inputs.env }}
25+
tag_version: ${{ github.event.inputs.tag_version }}
26+
chart_path: chart/gateway-medcat/Chart.yaml
27+
git_ref: main
28+
run_scan: true
29+
secrets: inherit
Lines changed: 28 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,46 @@
11
name: Build and deploy to DEV
2-
run-name: ${{ github.actor }} triggered deploy to DEV pipeline
2+
run-name: ${{ github.actor }} triggered deploy to DEV pipeline
33

44
on:
55
push:
66
branches:
7-
- "dev"
8-
9-
env:
10-
PROJECT_ID: "${{ secrets.PROJECT_ID }}"
11-
GAR_LOCATION: "${{ secrets.GAR_LOCATION }}"
12-
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL}}"
13-
SLACK_CHANNEL: "${{ secrets.GITHUBACTIONS_SLACK_CHANNEL }}"
7+
- dev
148

159
jobs:
16-
build:
17-
permissions:
18-
contents: write
19-
id-token: write
20-
10+
setup:
2111
runs-on: ubuntu-latest
2212
environment: dev
13+
outputs:
14+
docker_build_args: ${{ steps.args.outputs.docker_build_args }}
2315
steps:
24-
- name: Checkout
25-
uses: actions/checkout@v6
26-
with:
27-
ref: dev
16+
- uses: actions/checkout@v6
2817

2918
- name: Read BASE IMAGE VERSION file
3019
id: getappversion
31-
run: echo "appversion=$(sed -n 's/^MEDCAT_BASE_IMAGE_VERSION=\(.*\)/\1/p' < medcat_versions.yml)" >> "$GITHUB_OUTPUT"
32-
33-
- name: Read MEDCAT VERSION
34-
id: getversion
35-
run: |
36-
sed -n 's/^appVersion:\(.*\)/\1/p' < "chart/gateway-medcat/Chart.yaml" > "version"
37-
echo "version=$(sed 's/.*\"\(.*\)\".*/\1/g' "version")" >> "$GITHUB_OUTPUT"
38-
39-
- name: Google Auth
40-
id: auth
41-
uses: "google-github-actions/auth@v2"
42-
with:
43-
token_format: "access_token"
44-
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
45-
service_account: "${{ secrets.WIF_SERVICE_ACCOUNT }}"
20+
run: |
21+
echo "appversion=$(sed -n 's/^MEDCAT_BASE_IMAGE_VERSION=\(.*\)/\1/p' medcat_versions.yml)" >> "$GITHUB_OUTPUT"
4622
47-
- name: "Set up Cloud SDK"
48-
uses: "google-github-actions/setup-gcloud@v2"
49-
with:
50-
version: ">= 363.0.0"
23+
- id: args
24+
run: |
25+
ARGS=""
26+
ARGS+="--build-arg MEDCAT_BASE_IMAGE_VERSION=${{ steps.getappversion.outputs.appversion }} "
27+
echo "docker_build_args=$ARGS" >> "$GITHUB_OUTPUT"
5128
52-
- name: "Use gcloud CLI to download the models from google storage bucket"
53-
run: gsutil -m cp -r '${{ secrets.BUCKET_PATH }}' .
54-
55-
- name: Login to GAR
56-
id: garlogin
57-
uses: docker/login-action@v3
58-
with:
59-
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.PROJECT_ID }}
60-
username: oauth2accesstoken
61-
password: ${{ steps.auth.outputs.access_token }}
62-
63-
- name: Build and Push Container
64-
id: build
65-
shell: bash
66-
env:
67-
GAR_LOCATION: ${{ secrets.GAR_LOCATION }}
68-
PROJECT_ID: ${{ secrets.PROJECT_ID }}
69-
GAR_NAME: ${{ secrets.GAR_NAME }}
70-
71-
run: |-
72-
docker build -t '${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}:${{ github.sha }} -t '${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}:latest --build-arg MEDCAT_BASE_IMAGE_VERSION=${{ steps.getappversion.outputs.appversion }} ./
73-
docker push --all-tags '${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}
29+
build:
30+
needs: setup
31+
uses: HDRUK/github-actions-templates/.github/workflows/docker-build.yaml@main
32+
with:
33+
chart_path: chart/gateway-medcat/Chart.yaml
34+
environment: dev
35+
docker_build_args: ${{ needs.setup.outputs.docker_build_args }}
36+
download_models: true
37+
secrets: inherit
7438

7539
deploy:
7640
needs: build
77-
permissions:
78-
contents: write
79-
id-token: write
80-
81-
runs-on: ubuntu-latest
82-
environment: dev
83-
steps:
84-
- name: Checkout
85-
uses: actions/checkout@v6
86-
with:
87-
ref: dev
88-
89-
- name: Google Auth
90-
id: auth
91-
uses: "google-github-actions/auth@v2"
92-
with:
93-
token_format: "access_token"
94-
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
95-
service_account: "${{ secrets.WIF_SERVICE_ACCOUNT }}"
96-
97-
- name: Read MEDCAT VERSION
98-
id: getversion
99-
run: |
100-
sed -n 's/^appVersion:\(.*\)/\1/p' < "chart/gateway-medcat/Chart.yaml" > "version"
101-
echo "version=$(sed 's/.*\"\(.*\)\".*/\1/g' "version")" >> "$GITHUB_OUTPUT"
102-
103-
- name: Deploy to Cloud Run
104-
uses: actions-hub/gcloud@540.0.0
105-
id: deploy
106-
env:
107-
PROJECT_ID: ${{ secrets.PROJECT_ID }}
108-
GAR_LOCATION: ${{ secrets.GAR_LOCATION }}
109-
GAR_NAME: ${{ secrets.GAR_NAME }}
110-
SERVICE_NAME: "${{ secrets.SERVICE_NAME }}"
111-
SERVICE_REGION: "${{ secrets.SERVICE_REGION }}"
112-
113-
with:
114-
args: run services update '${{ env.SERVICE_NAME }}' --image='${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}:${{ github.sha }} --region='${{ env.SERVICE_REGION }}' --project='${{ env.PROJECT_ID }}'
115-
116-
- name: Run Notification
117-
id: runnotificationsent
118-
uses: act10ns/slack@v1
119-
with:
120-
status: ${{ job.status }}
121-
steps: ${{ toJson(steps) }}
122-
channel: ${{ env.SLACK_CHANNEL }}
123-
message: Deploying {{ env.GITHUB_REF_NAME }} branch to DEV ${{ job.status }}
124-
if: always()
41+
uses: HDRUK/github-actions-templates/.github/workflows/deploy-release.yml@main
42+
with:
43+
env: dev
44+
chart_path: chart/gateway-medcat/Chart.yaml
45+
git_ref: dev
46+
secrets: inherit
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Tag Jira fix version
2+
run-name: ${{ github.actor }} tagging Jira fix version for ${{ github.ref_name }}
3+
4+
# Runs on temporary release branches. Delegates to the reusable workflow, which
5+
# generates the release-notes preview, derives the version from the branch name
6+
# (release/1.12.0 -> 1.12.0), and tags the referenced Jira tickets.
7+
on:
8+
push:
9+
branches:
10+
- "release/*"
11+
12+
jobs:
13+
jira:
14+
uses: HDRUK/github-actions-templates/.github/workflows/jira-fix-version.yml@main
15+
with:
16+
jira_projects: "GAT"
17+
secrets: inherit
Lines changed: 7 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,15 @@
11
name: PR Title Validation
22

3+
permissions:
4+
contents: read
5+
actions: read
6+
37
on:
48
pull_request:
59
types: [opened, edited, synchronize]
610

11+
712
jobs:
813
check-title:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- name: Generate GitHub App token
12-
id: generate-deployment-token
13-
uses: actions/create-github-app-token@v2
14-
with:
15-
app-id: ${{ secrets.DEPLOY_APP_ID }}
16-
private-key: ${{ secrets.DEPLOY_APP_PRIVATE_KEY }}
17-
owner: HDRUK
18-
repositories: |
19-
${{ github.event.repository.name }}
20-
21-
- name: Check PR Title Format
22-
env:
23-
GITHUB_TOKEN: ${{ steps.generate-deployment-token.outputs.token }}
24-
PR_TITLE: ${{ github.event.pull_request.title }}
25-
PR_NUMBER: ${{ github.event.pull_request.number }}
26-
PR_REPO: ${{ github.repository }}
27-
run: |
28-
TITLE="$PR_TITLE"
29-
REPO="$PR_REPO"
30-
31-
echo "PR Title: $TITLE"
32-
33-
# Define regex patterns
34-
RELEASE_PATTERN="^RELEASE: .+$"
35-
STANDARD_PATTERN="^(feat|fix|chore|docs|style|refactor|test|perf)(!?)\(GAT-[0-9]+\): .+$"
36-
37-
if echo "$TITLE" | grep -E -q "$RELEASE_PATTERN"; then
38-
echo "✅ PR title is a valid RELEASE PR!"
39-
40-
COMMENT="🎉 **Great job!** Your PR title follows the correct format for a release. 🚀"
41-
elif echo "$TITLE" | grep -E -q "$STANDARD_PATTERN"; then
42-
echo "✅ PR title is valid!"
43-
44-
COMMENT="🎉 **Great job!** Your PR title follows the correct format. 🚀"
45-
else
46-
echo "❌ Invalid PR title format!"
47-
48-
COMMENT="🚨 **Invalid PR title format!**\n\nYour PR title must follow one of these formats:\n- \`feat(GAT-1234): Your title\`\n- \`fix!(GAT-5678): Breaking change\`\n- \`RELEASE: vX.Y.Z\`\n\nPlease update your PR title accordingly. 😊"
49-
50-
curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
51-
-H "Accept: application/vnd.github.v3+json" \
52-
"https://api.github.com/repos/$REPO/issues/$PR_NUMBER/comments" \
53-
-d "{\"body\": \"$COMMENT\"}"
54-
55-
exit 1
56-
fi
57-
58-
# Check if an existing comment already exists
59-
EXISTING_COMMENT=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
60-
"https://api.github.com/repos/$REPO/issues/$PR_NUMBER/comments" | jq -r '.[] | select(.body | contains("Great job!")) | .id')
61-
62-
if [[ -z "$EXISTING_COMMENT" ]]; then
63-
curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
64-
-H "Accept: application/vnd.github.v3+json" \
65-
"https://api.github.com/repos/$REPO/issues/$PR_NUMBER/comments" \
66-
-d "{\"body\": \"$COMMENT\"}"
67-
fi
14+
uses: HDRUK/github-actions-templates/.github/workflows/pr-title-check.yml@main
15+
secrets: inherit

0 commit comments

Comments
 (0)