This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
306c389
commit df175ba
Showing
1 changed file
with
30 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
name: Deploy to Azure Container Apps | ||
|
||
on: | ||
|
@@ -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 |