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