Skip to content

Feature/azure deploys (#152) #140

Feature/azure deploys (#152)

Feature/azure deploys (#152) #140

name: Build and deploy container (Production)
on:
push:
branches: [ main ]
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
runs-on: ubuntu-latest
steps:
# Setup environment
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-$latest
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
cache-from: type=local,src=/tmp/.buildx-cache
target: deploy
push: true
tags: |
${{ vars.REGISTRY_REPO_PATH }}:latest
${{ vars.REGISTRY_REPO_PATH }}:${{ github.sha }}
# Clean up cache
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
deploy:
runs-on: ubuntu-latest
environment:
name: production
url: api.hackthe6ix.com
steps:
- name: Log in to Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy Container App
uses: azure/cli@v2
with:
azcliversion: 2.74.0
inlineScript: |
az containerapp update -n ${{ vars.CONTAINER_APP_NAME }} -g ${{ vars.CONTAINER_APP_RESOURCE_GROUP }} –image ${{ vars.REGISTRY_REPO_PATH }}:${{ github.sha }}