Skip to content

Commit f1271eb

Browse files
committed
Add dependency on semantic job for build step
1 parent 5428805 commit f1271eb

1 file changed

Lines changed: 28 additions & 140 deletions

File tree

Lines changed: 28 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,40 @@
11
name: Semantic Release workflow
2-
run-name: ${{ github.actor }} Semantic Release workflow
32

43
on:
54
push:
65
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 }}"
6+
- main
147

158
jobs:
16-
semantic:
17-
permissions: write-all
18-
runs-on: ubuntu-latest
19-
steps:
20-
- name: Generate GitHub App token
21-
id: generate-deployment-token
22-
uses: actions/create-github-app-token@v2
23-
with:
24-
app-id: ${{ secrets.DEPLOY_APP_ID }}
25-
private-key: ${{ secrets.DEPLOY_APP_PRIVATE_KEY }}
26-
owner: HDRUK
27-
repositories: |
28-
${{ github.event.repository.name }}
29-
30-
- name: Checkout
31-
id: checkout
32-
uses: actions/checkout@v6
33-
with:
34-
token: ${{ steps.generate-deployment-token.outputs.token }}
35-
ref: main
36-
fetch-depth: 0
37-
38-
- name: Set up Node.js
39-
uses: actions/setup-node@v5
40-
with:
41-
node-version: ${{ env.NODE_VERSION }}
42-
43-
- name: Install dependencies
44-
run: npm install
45-
46-
- name: Run Semantic Release
47-
run: npx semantic-release
48-
env:
49-
JIRA_URL: ${{ vars.JIRA_URL }}
50-
GITHUB_TOKEN: ${{ steps.generate-deployment-token.outputs.token }}
51-
52-
- name: Set Git config
53-
run: |
54-
git config --local user.email "actions@github.com"
55-
git config --local user.name "Github Actions"
56-
57-
- name: Fetch latest changes from main
58-
run: |
59-
git fetch origin main
60-
git reset --hard origin/main
61-
62-
- name: Read VERSION file
63-
id: getversion
64-
run: |
65-
sed -n 's/^appVersion:\(.*\)/\1/p' < "chart/gateway-medcat/Chart.yaml" > "version"
66-
echo "version=$(sed 's/.*\"\(.*\)\".*/\1/g' "version")" >> "$GITHUB_OUTPUT"
67-
68-
- name: Merge changes from main to dev
69-
env:
70-
GITHUB_TOKEN: ${{ steps.generate-deployment-token.outputs.token }}
71-
RELEASE_VERSION: ${{ steps.getversion.outputs.version }}
72-
run: |
73-
git fetch origin dev
74-
git checkout dev
75-
git merge --squash origin/main || true
76-
git checkout --theirs . || true
77-
git add .
78-
git commit --allow-empty -m "sync: update dev with latest main changes from release ${RELEASE_VERSION} (squash sync) [skip ci]"
79-
git push origin dev
80-
81-
build:
82-
needs: semantic
83-
permissions:
84-
contents: write
85-
id-token: write
9+
semantic:
10+
uses: HDRUK/github-actions-templates/.github/workflows/semantic.yaml@main
11+
with:
12+
chart_path: chart/gateway-medcat/Chart.yaml
13+
secrets: inherit
8614

15+
setup-prod:
8716
runs-on: ubuntu-latest
88-
environment: release
17+
environment: prod
18+
needs: semantic
19+
outputs:
20+
docker_build_args: ${{ steps.args.outputs.docker_build_args }}
8921
steps:
90-
- name: Checkout
91-
id: checkout
92-
uses: actions/checkout@v6
93-
with:
94-
ref: main
95-
9622
- name: Read BASE IMAGE VERSION file
9723
id: getappversion
98-
run: echo "appversion=$(sed -n 's/^MEDCAT_BASE_IMAGE_VERSION=\(.*\)/\1/p' < medcat_versions.yml)" >> "$GITHUB_OUTPUT"
99-
100-
- name: Read MEDCAT VERSION
101-
id: getversion
102-
run: |
103-
sed -n 's/^appVersion:\(.*\)/\1/p' < "chart/gateway-medcat/Chart.yaml" > "version"
104-
echo "version=$(sed 's/.*\"\(.*\)\".*/\1/g' "version")" >> "$GITHUB_OUTPUT"
105-
106-
- name: Google Auth
107-
id: auth
108-
uses: "google-github-actions/auth@v2"
109-
with:
110-
token_format: "access_token"
111-
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
112-
service_account: "${{ secrets.WIF_SERVICE_ACCOUNT }}"
113-
114-
- name: "Set up Cloud SDK"
115-
id: setupsdk
116-
uses: "google-github-actions/setup-gcloud@v2"
117-
with:
118-
version: ">= 363.0.0"
119-
120-
- name: "Use gcloud CLI to download the models from google storage bucket"
121-
id: copymodel
122-
run: gsutil -m cp -r '${{ secrets.BUCKET_PATH }}' .
123-
124-
- name: Login to GAR
125-
id: garlogin
126-
uses: docker/login-action@v3
127-
with:
128-
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.PROJECT_ID }}
129-
username: oauth2accesstoken
130-
password: ${{ steps.auth.outputs.access_token }}
131-
132-
- name: Build and Push Container
133-
id: build
134-
shell: bash
135-
env:
136-
GAR_LOCATION: ${{ secrets.GAR_LOCATION }}
137-
PROJECT_ID: ${{ secrets.PROJECT_ID }}
138-
GAR_NAME: ${{ secrets.GAR_NAME }}
139-
140-
run: |-
141-
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 }} ./
142-
docker push --all-tags '${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}
143-
144-
- name: Run Notification
145-
id: runnotificationsent
146-
uses: act10ns/slack@v1
147-
with:
148-
status: ${{ job.status }}
149-
steps: ${{ toJson(steps) }}
150-
channel: ${{ env.SLACK_CHANNEL }}
151-
message: Running release build on {{ env.GITHUB_REF_NAME }} branch ${{ job.status }}
152-
if: always()
24+
run: |
25+
echo "appversion=$(sed -n 's/^MEDCAT_BASE_IMAGE_VERSION=\(.*\)/\1/p' < medcat_versions.yml)" >> "$GITHUB_OUTPUT"
26+
27+
- id: args
28+
run: |
29+
ARGS=""
30+
ARGS+="--build-arg MEDCAT_BASE_IMAGE_VERSION=${{ steps.getappversion.outputs.appversion }} "
31+
echo "docker_build_args=$ARGS" >> "$GITHUB_OUTPUT"
32+
33+
build-prod:
34+
needs: setup-prod
35+
uses: HDRUK/github-actions-templates/.github/workflows/docker-build.yaml@main
36+
with:
37+
environment: prod
38+
docker_build_args: ${{ needs.setup-prod.outputs.docker_build_args }}
39+
chart_path: chart/gateway-medcat/Chart.yaml
40+
secrets: inherit

0 commit comments

Comments
 (0)