Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mUusitalo committed Sep 3, 2024
1 parent 275e6d2 commit d447ece
Showing 1 changed file with 51 additions and 15 deletions.
66 changes: 51 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,69 @@ on:
push:
branches:
- android-fix-wip
workflow_dispatch:

permissions:
id-token: write

env:
AZURE_CORE_OUTPUT: none

jobs:
build-and-deploy:
build:
runs-on: ubuntu-latest
environment:
name: 'Production'

environment: Production
steps:
- uses: actions/checkout@v2

- name: Login via Azure CLI
uses: azure/login@v1
- name: Log in to Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
client-id: ${{ secrets.CLIENT_ID }}
tenant-id: ${{ secrets.TENANT_ID }}
allow-no-subscriptions: true

- name: Docker login to ACR
uses: azure/docker-login@v1
run: az acr login --name ${{ secrets.REGISTRY_NAME }}

- name: Build and push image
uses: docker/build-push-action@v5
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
context: .
push: true
tags: ${{ secrets.REGISTRY_NAME }}.azurecr.io/kiltiskamera/kamera:${{ github.sha }}
cache-from: type=gha,ref=${{ github.ref_name }}
cache-to: type=gha,mode=max
network: host

- name: Azure logout
run: |
az logout
deploy:
runs-on: ubuntu-latest
environment: production
needs: build
steps:
- uses: actions/checkout@v2
- name: Log in to Azure
uses: Azure/login@v2
with:
client-id: ${{ secrets.CLIENT_ID }}
tenant-id: ${{ secrets.TENANT_ID }}
allow-no-subscriptions: true

- name: Docker login to ACR
run: az acr login --name ${{ secrets.REGISTRY_NAME }}

- name: Build and push
# Would like to use azure/webapps-deploy but it doesn't seem to work with OIDC.
- name: Deploy from ACR
run: |
docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/kiltiskamera/kamera
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/kiltiskamera/kamera
az webapp config container set \
--container-image-name ${{ secrets.REGISTRY_NAME }}.azurecr.io/kiltiskamera/kamera:${{ github.sha }} \
--container-registry-url https://${{ secrets.REGISTRY_NAME }}.azurecr.io \
--subscription ${{ secrets.SUBSCRIPTION }} \
--resource-group prodeko-rg \
--name kiltiskamera
- name: Azure logout
run: |
Expand Down

0 comments on commit d447ece

Please sign in to comment.