This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Azure Container Apps | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }} | |
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }} | |
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }} | |
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }} | |
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Inject Secrets into YAML | |
run: | | |
sed -i 's#{DB_URL}#${{ secrets.DB_URL }}#' server/src/main/resources/application.yml | |
sed -i 's#{DB_USERNAME}#${{ secrets.DB_USERNAME }}#' server/src/main/resources/application.yml | |
sed -i 's#{DB_PASSWORD}#${{ secrets.DB_PASSWORD }}#' server/src/main/resources/application.yml | |
- name: Build with Gradle | |
run: | | |
cd server | |
./gradlew build -x test | |
- name: Log in to Docker Registry | |
uses: azure/docker-login@v1 | |
with: | |
login-server: ${{ secrets.AZURE_CONTAINER_REGISTRY }} | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and Push Docker Image | |
run: | | |
cd server | |
docker build . -t ${{ secrets.AZURE_CONTAINER_REGISTRY }}/server:latest | |
docker push ${{ secrets.AZURE_CONTAINER_REGISTRY }}/server:latest | |
- name: Deploy to Azure Container Apps | |
run: | | |
az containerapp update --name ${{ vars.AZURE_APP_NAME }} \ | |
--resource-group ${{ vars.AZURE_RESOURCE_GROUP }} \ | |
--image ${{ secrets.AZURE_CONTAINER_REGISTRY }}/server:latest |