Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
dongchandev committed Aug 27, 2024
1 parent 306c389 commit df175ba
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions .github/workflows/azure-dev.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

name: Deploy to Azure Container Apps

on:
Expand All @@ -23,38 +24,50 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/checkout@v3
- 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: Install azd
uses: Azure/[email protected]

- name: Log in to Docker Registry
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.AZURE_CONTAINER_REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Build and Push Docker Image
- name: Log in with Azure (Federated Credentials)
if: ${{ env.AZURE_CLIENT_ID != '' }}
run: |
cd server
docker build . -t ${{ secrets.AZURE_CONTAINER_REGISTRY }}/server:latest
docker push ${{ secrets.AZURE_CONTAINER_REGISTRY }}/server:latest
azd auth login `
--client-id "$Env:AZURE_CLIENT_ID" `
--federated-credential-provider "github" `
--tenant-id "$Env:AZURE_TENANT_ID"
shell: pwsh

- name: Deploy to Azure Container Apps
- name: Log in with Azure (Client Credentials)
if: ${{ env.AZURE_CREDENTIALS != '' }}
run: |
az containerapp update --name ${{ vars.AZURE_APP_NAME }} \
--resource-group ${{ vars.AZURE_RESOURCE_GROUP }} \
--image ${{ secrets.AZURE_CONTAINER_REGISTRY }}/server:latest
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
azd auth login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
shell: pwsh
env:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}

- name: Provision Infrastructure
run: azd provision --no-prompt
env:
AZD_INITIAL_ENVIRONMENT_CONFIG: ${{ secrets.AZD_INITIAL_ENVIRONMENT_CONFIG }}

- name: Deploy Application
run: azd deploy --no-prompt

0 comments on commit df175ba

Please sign in to comment.