This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
Update azure-dev.yml #142
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
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- master | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Inject Secrets into YAML | |
run: | | |
sed -i 's#{KEY}#${{ secrets.KEY }}#' server/src/main/resources/application.yml | |
sed -i 's#{ENDPOINT}#${{ secrets.ENDPOINT }}#' server/src/main/resources/application.yml | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "21" | |
distribution: "zulu" | |
- name: Build with Gradle | |
run: | | |
cd server | |
./gradlew clean build | |
- name: Log in to Azure | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ vars.AZURE_CLIENT_ID }} | |
tenant-id: ${{ vars.AZURE_TENANT_ID }} | |
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }} | |
- name: Log in to Docker Registry | |
uses: azure/docker-login@v1 | |
with: | |
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }} | |
username: ${{ secrets.REGISTRY_USERNAME }} | |
password: ${{ secrets.REGISTRY_PASSWORD }} | |
- name: Build and Push Docker Image | |
run: | | |
cd server | |
docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/server:${{ github.sha }} | |
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/server:${{ github.sha }} | |
- name: Add Azure Container Apps Extension | |
run: az extension add --name containerapp --upgrade | |
- name: Create Container App Environment | |
run: az containerapp env create --name ${{ vars.AZURE_ENV_NAME }} --location ${{ vars.AZURE_LOCATION }} --resource-group rg-${{ vars.AZURE_ENV_NAME }} | |
- name: Deploy Server App | |
run: az containerapp create --name server-app --image ${{ secrets.REGISTRY_LOGIN_SERVER }}/server:${{ github.sha }} --environment ${{ vars.AZURE_ENV_NAME }} --resource-group rg-${{ vars.AZURE_ENV_NAME }} --target-port 8080 --ingress 'external' --registry-server ${{ secrets.REGISTRY_LOGIN_SERVER }} --registry-username ${{ secrets.REGISTRY_USERNAME }} --registry-password ${{ secrets.REGISTRY_PASSWORD }} | |
- name: Get FQDN From Server | |
run: | | |
export FQDN=$(az containerapp show --resource-group rg-${{ vars.AZURE_ENV_NAME }} --name server-app --query properties.configuration.ingress.fqdn --output tsv) | |
echo "REACT_APP_SERVER_URL=${FQDN}" >> $GITHUB_ENV | |
- name: Build and Push Docker Image | |
run: | | |
pwd | |
cd web | |
docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/web:${{ github.sha }} | |
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/web:${{ github.sha }} | |
- name: Deploy Web App | |
run: | | |
echo "REACT_APP_SERVER_URL=$REACT_APP_SERVER_URL" | |
az containerapp create --name web-app --image ${{ secrets.REGISTRY_LOGIN_SERVER }}/web:${{ github.sha }} --environment ${{ vars.AZURE_ENV_NAME }} --resource-group rg-${{ vars.AZURE_ENV_NAME }} --target-port 3000 --ingress 'external' --registry-server ${{ secrets.REGISTRY_LOGIN_SERVER }} --registry-username ${{ secrets.REGISTRY_USERNAME }} --registry-password ${{ secrets.REGISTRY_PASSWORD }} --env-vars REACT_APP_SERVER_URL=$REACT_APP_SERVER_URL | |