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: Build and deploy JAR app to Azure Container App - hilfling-backend | |
on: | |
push: | |
branches: | |
- feature/fg-137 | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Java version | |
uses: actions/setup-java@v1 | |
with: | |
java-version: "21" | |
- name: Build Docker backend image | |
run: | | |
docker build \ | |
--build-arg DATABASE_USERNAME=${{ secrets.HILFLINGDB_USERNAME }} \ | |
--build-arg DATABASE_URL=${{ secrets.HILFLINGDB_URL_DEV }} \ | |
--build-arg DATABASE_PASSWORD=${{ secrets.HILFLINGDB_PASSWORD }} \ | |
-t hilfling-backend:${{ github.sha }} . | |
- name: Log in to Azure Container Registry | |
uses: azure/docker-login@v1 | |
with: | |
login-server: ${{ secrets.ACR_LOGIN_SERVER }} | |
username: ${{ secrets.ACR_USERNAME }} | |
password: ${{ secrets.ACR_PASSWORD }} | |
- name: Push Docker backend image to Azure Container Registry | |
run: | | |
docker tag hilfling-backend:${{ github.sha }} ${{ secrets.ACR_LOGIN_SERVER }}/hilfling-backend:${{ github.sha }} | |
docker push ${{ secrets.ACR_LOGIN_SERVER }}/hilfling-backend:${{ github.sha }} | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Azure CLI Login | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Log in to Azure Container Registry | |
uses: azure/docker-login@v1 | |
with: | |
login-server: ${{ secrets.ACR_LOGIN_SERVER }} | |
username: ${{ secrets.ACR_USERNAME }} | |
password: ${{ secrets.ACR_PASSWORD }} | |
- name: Delete existing Azure Container Apps (if any) | |
run: | | |
az containerapp delete \ | |
--name hilfling-backend1 \ | |
--resource-group hilfling-backend_group \ | |
--yes || true | |
- name: Deploy to Azure Container App | |
run: | | |
az containerapp create \ | |
--name hilfling-backend1 \ | |
--resource-group hilfling-backend_group \ | |
--environment hilfling-environment \ | |
--image ${{ secrets.ACR_LOGIN_SERVER }}/hilfling-backend:${{ github.sha }} \ | |
--cpu 1 --memory 2Gi \ | |
--env-vars DATABASE_USERNAME=${{ secrets.HILFLINGDB_USERNAME }} \ | |
DATABASE_URL=${{ secrets.HILFLINGDB_URL_DEV }} \ | |
DATABASE_PASSWORD=${{ secrets.HILFLINGDB_PASSWORD }} \ | |
--ingress 'external' \ | |
--query properties.configuration.ingress.fqdn | |
--target-port 8000 \ | |