Skip to content

Commit 0a5166f

Browse files
committed
supports deploying to both Azure CR (legacy) and GHCR
1 parent 5c5fcf7 commit 0a5166f

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

.github/workflows/build_container.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@ jobs:
3636
with:
3737
creds: ${{ secrets.AZURE_CREDENTIALS }}
3838

39-
- name: 'Login to Container Registry'
39+
- name: 'Login to Azure Container Registry'
4040
uses: azure/docker-login@v2
4141
with:
4242
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
4343
username: ${{ secrets.REGISTRY_USERNAME }}
4444
password: ${{ secrets.REGISTRY_PASSWORD }}
45+
46+
- name: 'Login to GitHub Container Registry'
47+
uses: docker/login-action@v1
48+
with:
49+
registry: ghcr.io
50+
username: ${{github.actor}}
51+
password: ${{secrets.GITHUB_TOKEN}}
4552

4653
- name: Update version (production)
4754
if: ${{ inputs.latest }}
@@ -51,14 +58,21 @@ jobs:
5158
5259
- name: 'Build and push image'
5360
run: |
54-
docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ env.VERSION }} \
61+
# build and push to GitHub Container Registry
62+
docker build . -t ghcr.io/The-Strategy-Unit/nhp_model:${{ env.VERSION }} \
5563
--build-arg app_version=${{ inputs.app-version }} \
5664
--build-arg data_version=${{ inputs.data-version }} \
5765
--build-arg storage_account=${{ secrets.NHP_STORAGE_ACCOUNT }}
66+
docker push ghcr.io/The-Strategy-Unit/nhp_model:${{ env.VERSION }}
67+
# push to Azure Container Registry (where the app currently run from)
68+
docker tag ghcr.io/The-Strategy-Unit/nhp_model:${{ env.VERSION }} ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ env.VERSION }}
5869
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ env.VERSION }}
5970
6071
- name: 'Push latest'
6172
if: ${{ inputs.latest }}
6273
run: |
63-
docker tag ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:${{ env.VERSION }} ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:latest
74+
docker tag ghcr.io/The-Strategy-Unit/nhp_model:${{ env.VERSION }} ghcr.io/The-Strategy-Unit/nhp_model:latest
75+
docker push ghcr.io/The-Strategy-Unit/nhp_model:latest
76+
77+
docker tag ghcr.io/The-Strategy-Unit/nhp_model:${{ env.VERSION }} ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:latest
6478
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/nhp_model:latest

0 commit comments

Comments
 (0)