Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci fix #12

Merged
merged 7 commits into from
Oct 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 61 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,79 @@ on:
push:
branches:
- placeholder
- android-fix-wip
- main
- ci-fix
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: Set up Docker buildx
uses: docker/setup-buildx-action@v3

- name: Build and push image
uses: docker/build-push-action@v5
with:
context: app
push: true
tags: ${{ secrets.REGISTRY_NAME }}.azurecr.io/kiltiskamera/backend:${{ github.sha }}
cache-from: type=gha,ref=${{ github.ref_name }}
cache-to: type=gha,mode=max
allow: |
network.host
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:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
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/backend:${{ github.sha }} \
--container-registry-url https://${{ secrets.REGISTRY_NAME }}.azurecr.io \
--subscription ${{ secrets.SUBSCRIPTION }} \
--resource-group kiltiskamera_group \
--name kiltiskamera

- name: Azure logout
run: |
az logout
az logout
Loading