11name : 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
44on :
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
159jobs :
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
0 commit comments