Skip to content

chore: Update pipelines; fixed api docker #19

chore: Update pipelines; fixed api docker

chore: Update pipelines; fixed api docker #19

Workflow file for this run

name: Deploy API
on:
workflow_dispatch:
push:
branches:
- main
- develop
paths: ['apps/api/**', '.github/workflows/deploy-api.yml', 'package.json']
jobs:
build:
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }}
name: Build and push API docker image for release
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker Login
uses: azure/docker-login@v2
with:
login-server: ${{ vars.ACR_REGISTRY_URL }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Build Docker image
id: build
env:
ACR_REGISTRY_URL: ${{ vars.ACR_REGISTRY_URL }}
REPOSITORY_NAME: api
run: |
# Build a docker container and push it to ACR
docker build -t $ACR_REGISTRY_URL/$REPOSITORY_NAME:${GITHUB_SHA::6} -t $ACR_REGISTRY_URL/$REPOSITORY_NAME:latest -f ./apps/web/Dockerfile .
echo "Pushing image to ACR..."
docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:latest
docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:${GITHUB_SHA::6}
echo "name=image::$ACR_REGISTRY_URL/$REPOSITORY_NAME:latest" >> $GITHUB_OUTPUT
deploy:
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }}
name: Restart API container app
needs: build
steps:
- name: Azure Login action
uses: azure/login@v2
with:
creds: ${{ secrets.CONTAINER_APP_SP_CREDENTIALS }}
enable-AzPSSession: true
- name: Azure CLI script
uses: azure/cli@v2
env:
API_CONTAINER: ${{ vars.API_CONTAINER }}
API_CONTAINER_RG: ${{ vars.API_CONTAINER_RG }}
with:
azcliversion: latest
inlineScript: |
az containerapp restart --name $API_CONTAINER --resource-group $API_CONTAINER_RG