11on :
22 workflow_call :
33 inputs :
4+ docker-tag :
5+ required : true
6+ default : dev
7+ type : string
48 app-version :
59 required : true
6- type : string
10+ default : dev
11+ type : string
712 data-version :
813 required : true
14+ default : dev
915 type : string
1016 latest :
1117 required : false
2430 required : true
2531
2632jobs :
27- get-version :
28- runs-on : ubuntu-latest
29- env :
30- # replaced progamatically if deploying to production
31- VERSION : dev
32- outputs :
33- version : ${{ steps.set-outputs.outputs.VERSION }}
34- steps :
35- - name : Update version (production)
36- if : ${{ inputs.latest }}
37- run : |
38- VERSION=`echo ${{ inputs.app-version }} | awk 'BEGIN { FS="."; } { print ""$1"."$2; }'`
39- echo "VERSION=$VERSION" >> $GITHUB_ENV
40-
41- - name : Set outputs
42- id : set-outputs
43- run : echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
44-
4533 build-and-deploy-ghcr :
4634 runs-on : ubuntu-latest
47- needs : [get-version]
4835 steps :
4936 - name : ' Checkout GitHub Action'
5037 uses : actions/checkout@v4
@@ -62,23 +49,22 @@ jobs:
6249
6350 - name : ' Build image'
6451 run : |
65- docker build . -t ghcr.io/the-strategy-unit/nhp_model:${{ needs.get-version.outputs.version }} \
52+ docker build . -t ghcr.io/the-strategy-unit/nhp_model:${{ inputs.docker-tag }} \
6653 --build-arg app_version=${{ inputs.app-version }} \
6754 --build-arg data_version=${{ inputs.data-version }}
6855
6956 - name : ' Push image'
7057 run : |
71- docker push ghcr.io/the-strategy-unit/nhp_model:${{ needs.get-version.outputs.version }}
58+ docker push ghcr.io/the-strategy-unit/nhp_model:${{ inputs.docker-tag }}
7259
7360 - name : ' Push latest'
7461 if : ${{ inputs.latest }}
7562 run : |
76- docker tag ghcr.io/the-strategy-unit/nhp_model:${{ needs.get-version.outputs.version }} ghcr.io/the-strategy-unit/nhp_model:latest
63+ docker tag ghcr.io/the-strategy-unit/nhp_model:${{ inputs.docker-tag }} ghcr.io/the-strategy-unit/nhp_model:latest
7764 docker push ghcr.io/the-strategy-unit/nhp_model:latest
7865
7966 build-and-deploy-acr :
8067 runs-on : ubuntu-latest
81- needs : [get-version]
8268 steps :
8369 - name : ' Checkout GitHub Action'
8470 uses : actions/checkout@v4
@@ -102,17 +88,17 @@ jobs:
10288 - name : ' Build and push image'
10389 run : |
10490 # include the storage account env var for the data for acr
105- docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ needs.get-version.outputs.version }} \
91+ docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ inputs.docker-tag }} \
10692 --build-arg app_version=${{ inputs.app-version }} \
10793 --build-arg data_version=${{ inputs.data-version }} \
10894 --build-arg storage_account=${{ secrets.NHP_STORAGE_ACCOUNT }}
10995
11096 - name : ' Push image'
11197 run : |
112- docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ needs.get-version.outputs.version }}
98+ docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ inputs.docker-tag }}
11399
114100 - name : ' Push latest'
115101 if : ${{ inputs.latest }}
116102 run : |
117- docker tag ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ needs.get-version.outputs.version }} ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:latest
103+ docker tag ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ inputs.docker-tag }} ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:latest
118104 docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:latest
0 commit comments