Skip to content

Commit d2c9cde

Browse files
committed
added release workflow pipeline
1 parent e0bb273 commit d2c9cde

6 files changed

Lines changed: 184 additions & 91 deletions

File tree

.github/workflows/actionlint.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Lint GitHub Workflows
2+
on:
3+
pull_request:
4+
paths:
5+
- ".github/workflows/**/*.yml"
6+
- ".github/workflows/**/*.yaml"
7+
push:
8+
paths:
9+
- ".github/workflows/**/*.yml"
10+
- ".github/workflows/**/*.yaml"
11+
jobs:
12+
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

.github/workflows/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ jobs:
3434
steps:
3535
- name: Checkout
3636
id: checkout
37-
uses: actions/checkout@v4
37+
uses: actions/checkout@v6
3838
with:
3939
ref: main
4040

4141
- name: Google Auth
4242
id: auth
43-
uses: "google-github-actions/auth@v2"
43+
uses: "google-github-actions/auth@v4"
4444
with:
4545
token_format: "access_token"
4646
project_id: "${{ secrets.PROJECT_ID }}"

.github/workflows/dev_deployment.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
environment: dev
2323
steps:
2424
- name: Checkout
25-
uses: actions/checkout@v3
25+
uses: actions/checkout@v6
2626
with:
2727
ref: dev
2828

@@ -33,12 +33,12 @@ jobs:
3333
- name: Read MEDCAT VERSION
3434
id: getversion
3535
run: |
36-
sed -n 's/^appVersion:\(.*\)/\1/p' < chart/gateway-medcat/Chart.yaml > version
37-
echo "version=$(sed '/.*\"\(.*\)\".*/ s//\1/g' version)" >> $GITHUB_OUTPUT
36+
sed -n 's/^appVersion:\(.*\)/\1/p' < "chart/gateway-medcat/Chart" > "version"
37+
echo "version=$(sed 's/.*\"\(.*\)\".*/\1/g' "version")" >> "$GITHUB_OUTPUT"
3838
3939
- name: Google Auth
4040
id: auth
41-
uses: "google-github-actions/auth@v2"
41+
uses: "google-github-actions/auth@v4"
4242
with:
4343
token_format: "access_token"
4444
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
@@ -54,7 +54,7 @@ jobs:
5454

5555
- name: Login to GAR
5656
id: garlogin
57-
uses: docker/login-action@v2
57+
uses: docker/login-action@v3
5858
with:
5959
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.PROJECT_ID }}
6060
username: oauth2accesstoken
@@ -82,13 +82,13 @@ jobs:
8282
environment: dev
8383
steps:
8484
- name: Checkout
85-
uses: actions/checkout@v3
85+
uses: actions/checkout@v6
8686
with:
8787
ref: dev
8888

8989
- name: Google Auth
9090
id: auth
91-
uses: "google-github-actions/auth@v0"
91+
uses: "google-github-actions/auth@v4"
9292
with:
9393
token_format: "access_token"
9494
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
@@ -97,8 +97,8 @@ jobs:
9797
- name: Read MEDCAT VERSION
9898
id: getversion
9999
run: |
100-
sed -n 's/^appVersion:\(.*\)/\1/p' < chart/gateway-medcat/Chart.yaml > version
101-
echo "version=$(sed '/.*\"\(.*\)\".*/ s//\1/g' version)" >> $GITHUB_OUTPUT
100+
sed -n 's/^appVersion:\(.*\)/\1/p' < "chart/gateway-medcat/Chart" > "version"
101+
echo "version=$(sed 's/.*\"\(.*\)\".*/\1/g' "version")" >> "$GITHUB_OUTPUT"
102102
103103
- name: Deploy to Cloud Run
104104
uses: actions-hub/gcloud@540.0.0

.github/workflows/pr-title-check.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ jobs:
1111
- name: Check PR Title Format
1212
env:
1313
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
PR_TITLE: ${{ github.event.pull_request.title }}
15+
PR_NUMBER: ${{ github.event.pull_request.number }}
16+
PR_REPO: ${{ github.repository }}
1417
run: |
15-
TITLE="${{ github.event.pull_request.title }}"
16-
PR_NUMBER="${{ github.event.pull_request.number }}"
17-
REPO="${{ github.repository }}"
18+
TITLE="$PR_TITLE"
19+
REPO="$PR_REPO"
1820
1921
echo "PR Title: $TITLE"
2022

.github/workflows/release.yml

Lines changed: 13 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ run-name: ${{ github.actor }} triggered Release workflow
44
on:
55
push:
66
branches:
7-
- "main"
7+
- "release/*"
88

99
env:
1010
PROJECT_ID: "${{ secrets.PROJECT_ID }}"
@@ -13,101 +13,37 @@ env:
1313
SLACK_CHANNEL: "${{ secrets.GITHUBACTIONS_SLACK_CHANNEL }}"
1414

1515
jobs:
16-
semantic:
17-
permissions: write-all
18-
runs-on: ubuntu-latest
19-
steps:
20-
- name: Checkout
21-
id: checkout
22-
uses: actions/checkout@v4
23-
with:
24-
token: ${{ secrets.GH_TOKEN }}
25-
ref: main
26-
fetch-depth: 0
27-
28-
- name: Set up Node.js
29-
uses: actions/setup-node@v3
30-
with:
31-
node-version: ${{ env.NODE_VERSION }}
32-
33-
- name: Install dependencies
34-
run: npm install
35-
36-
- name: Run Semantic Release
37-
run: npx semantic-release
38-
env:
39-
JIRA_URL: ${{ vars.JIRA_URL }}
40-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
41-
42-
- name: Set Git config
43-
run: |
44-
git config --local user.email "actions@github.com"
45-
git config --local user.name "Github Actions"
46-
47-
- name: Fetch latest changes from main
48-
run: |
49-
git fetch origin main
50-
git reset --hard origin/main
51-
52-
- name: Merge changes from main to dev
53-
env:
54-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
55-
run: |
56-
git fetch origin dev
57-
git checkout dev
58-
git merge --no-ff main || true
59-
git checkout --theirs .
60-
git add .
61-
git commit -m "Auto-resolve merge conflicts by keeping main's changes [skip ci]" || echo "No changes to commit"
62-
63-
git push origin dev
64-
6516
build:
66-
needs: semantic
17+
name: Build and Push Release Image
6718
permissions:
6819
contents: write
6920
id-token: write
7021

7122
runs-on: ubuntu-latest
7223
environment: release
7324
steps:
74-
- name: Checkout
75-
id: checkout
76-
uses: actions/checkout@v4
77-
with:
78-
ref: main
79-
80-
- name: Read BASE IMAGE VERSION file
81-
id: getappversion
82-
run: echo "appversion=$(sed -n 's/^MEDCAT_BASE_IMAGE_VERSION=\(.*\)/\1/p' < medcat_versions.yml)" >> $GITHUB_OUTPUT
25+
- name: Checkout repository
26+
uses: actions/checkout@v6
8327

84-
- name: Read MEDCAT VERSION
28+
- name: Extract version from branch
8529
id: getversion
86-
run: |
87-
sed -n 's/^appVersion:\(.*\)/\1/p' < chart/gateway-medcat/Chart.yaml > version
88-
echo "version=$(sed '/.*\"\(.*\)\".*/ s//\1/g' version)" >> $GITHUB_OUTPUT
30+
run: |
31+
branch="${GITHUB_REF_NAME}" # ex: release/1.23.4
32+
version="${branch#release/}" # strip prefix
33+
echo "version=$version" >> "$GITHUB_OUTPUT"
8934
9035
- name: Google Auth
9136
id: auth
92-
uses: "google-github-actions/auth@v2"
37+
uses: "google-github-actions/auth@v4"
9338
with:
9439
token_format: "access_token"
40+
project_id: "${{ secrets.PROJECT_ID }}"
9541
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
9642
service_account: "${{ secrets.WIF_SERVICE_ACCOUNT }}"
9743

98-
- name: "Set up Cloud SDK"
99-
id: setupsdk
100-
uses: "google-github-actions/setup-gcloud@v1"
101-
with:
102-
version: ">= 363.0.0"
103-
104-
- name: "Use gcloud CLI to download the models from google storage bucket"
105-
id: copymodel
106-
run: gsutil -m cp -r '${{ secrets.BUCKET_PATH }}' .
107-
10844
- name: Login to GAR
10945
id: garlogin
110-
uses: docker/login-action@v2
46+
uses: docker/login-action@v3
11147
with:
11248
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.PROJECT_ID }}
11349
username: oauth2accesstoken
@@ -133,4 +69,4 @@ jobs:
13369
steps: ${{ toJson(steps) }}
13470
channel: ${{ env.SLACK_CHANNEL }}
13571
message: Running release build on {{ env.GITHUB_REF_NAME }} branch ${{ job.status }}
136-
if: always()
72+
if: always()
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Semantic Release workflow
2+
run-name: ${{ github.actor }} Semantic Release workflow
3+
4+
on:
5+
push:
6+
branches:
7+
- "main"
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 }}"
14+
15+
jobs:
16+
semantic:
17+
permissions: write-all
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
id: checkout
22+
uses: actions/checkout@v6
23+
with:
24+
token: ${{ secrets.GH_TOKEN }}
25+
ref: main
26+
fetch-depth: 0
27+
28+
- name: Set up Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: ${{ env.NODE_VERSION }}
32+
33+
- name: Install dependencies
34+
run: npm install
35+
36+
- name: Run Semantic Release
37+
run: npx semantic-release
38+
env:
39+
JIRA_URL: ${{ vars.JIRA_URL }}
40+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
41+
42+
- name: Set Git config
43+
run: |
44+
git config --local user.email "actions@github.com"
45+
git config --local user.name "Github Actions"
46+
47+
- name: Fetch latest changes from main
48+
run: |
49+
git fetch origin main
50+
git reset --hard origin/main
51+
52+
- name: Merge changes from main to dev
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
55+
run: |
56+
git fetch origin dev
57+
git checkout dev
58+
git merge --no-ff main || true
59+
git checkout --theirs .
60+
git add .
61+
git commit -m "Auto-resolve merge conflicts by keeping main's changes [skip ci]" || echo "No changes to commit"
62+
63+
git push origin dev
64+
65+
build:
66+
needs: semantic
67+
permissions:
68+
contents: write
69+
id-token: write
70+
71+
runs-on: ubuntu-latest
72+
environment: release
73+
steps:
74+
- name: Checkout
75+
id: checkout
76+
uses: actions/checkout@v6
77+
with:
78+
ref: main
79+
80+
- name: Read BASE IMAGE VERSION file
81+
id: getappversion
82+
run: echo "appversion=$(sed -n 's/^MEDCAT_BASE_IMAGE_VERSION=\(.*\)/\1/p' < medcat_versions.yml)" >> $GITHUB_OUTPUT
83+
84+
- name: Read MEDCAT VERSION
85+
id: getversion
86+
run: |
87+
sed -n 's/^appVersion:\(.*\)/\1/p' < "chart/gateway-medcat/Chart" > "version"
88+
echo "version=$(sed 's/.*\"\(.*\)\".*/\1/g' "version")" >> "$GITHUB_OUTPUT"
89+
90+
- name: Google Auth
91+
id: auth
92+
uses: "google-github-actions/auth@v4"
93+
with:
94+
token_format: "access_token"
95+
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
96+
service_account: "${{ secrets.WIF_SERVICE_ACCOUNT }}"
97+
98+
- name: "Set up Cloud SDK"
99+
id: setupsdk
100+
uses: "google-github-actions/setup-gcloud@v1"
101+
with:
102+
version: ">= 363.0.0"
103+
104+
- name: "Use gcloud CLI to download the models from google storage bucket"
105+
id: copymodel
106+
run: gsutil -m cp -r '${{ secrets.BUCKET_PATH }}' .
107+
108+
- name: Login to GAR
109+
id: garlogin
110+
uses: docker/login-action@v3
111+
with:
112+
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.PROJECT_ID }}
113+
username: oauth2accesstoken
114+
password: ${{ steps.auth.outputs.access_token }}
115+
116+
- name: Build and Push Container
117+
id: build
118+
shell: bash
119+
env:
120+
GAR_LOCATION: ${{ secrets.GAR_LOCATION }}
121+
PROJECT_ID: ${{ secrets.PROJECT_ID }}
122+
GAR_NAME: ${{ secrets.GAR_NAME }}
123+
124+
run: |-
125+
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 }} ./
126+
docker push --all-tags '${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}
127+
128+
- name: Run Notification
129+
id: runnotificationsent
130+
uses: act10ns/slack@v1
131+
with:
132+
status: ${{ job.status }}
133+
steps: ${{ toJson(steps) }}
134+
channel: ${{ env.SLACK_CHANNEL }}
135+
message: Running release build on {{ env.GITHUB_REF_NAME }} branch ${{ job.status }}
136+
if: always()

0 commit comments

Comments
 (0)