added cloudflare config script #14
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: update-container-apps | |
on: | |
push: | |
paths: | |
- "api/**" | |
workflow_dispatch: | |
env: | |
DNS_ZONE_RG_NAME: 'external-domain-rg' | |
TEMPLATE_FILE_PATH: ./infra/main.bicep | |
PHOTO_API_NAME: 'photo' | |
PHOTO_API_PORT: 8080 | |
RESIZE_API_NAME: 'resize' | |
RESIZE_API_PORT: 8080 | |
VERSION: 1.0.0 | |
jobs: | |
get-vars-job: | |
runs-on: ubuntu-latest | |
outputs: | |
acrName: ${{ steps.get-acr.outputs.acrName }} | |
resizeApiImage: ${{ steps.gen-image-names.outputs.resizeApiImage }} | |
photoApiImage: ${{ steps.gen-image-names.outputs.photoApiImage }} | |
rgName: ${{ steps.gen-rg-name.outputs.rgName }} | |
steps: | |
- name: checkout-code | |
id: checkout-code | |
uses: actions/checkout@main | |
- name: gen-rg-name | |
id: gen-rg-name | |
run: | | |
echo "rgName: ${{ vars.APP_NAME }}-${{ vars.LOCATION }}-rg" | |
echo "rgName=${{ vars.APP_NAME }}-${{ vars.LOCATION }}-rg" >> "$GITHUB_OUTPUT" | |
echo "RG_NAME=${{ vars.APP_NAME }}-${{ vars.LOCATION }}-rg" >> "$GITHUB_ENV" | |
- name: short-sha | |
id: short-sha | |
run: | | |
echo "sha: sha=$(git rev-parse --short HEAD)" | |
echo "SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV" | |
- name: login-azure | |
id: login-azure | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: get-acr | |
id: get-acr | |
uses: azure/cli@v2 | |
with: | |
azcliversion: 2.67.0 | |
inlineScript: | | |
acrName=$(az acr list --resource-group $RG_NAME --query '[].name' --output tsv) | |
echo "ACR_NAME: $acrName" | |
echo "ACR_NAME=$acrName" >> "$GITHUB_ENV" | |
echo "acrName=$acrName" >> "$GITHUB_OUTPUT" | |
- name: gen-image-names | |
id: gen-image-names | |
run: | | |
echo "photoApiImage: ${{ env.ACR_NAME }}.azurecr.io/${{ env.PHOTO_API_NAME }}:${{ env.VERSION }}-$SHA" | |
echo "photoApiImage=${{ env.ACR_NAME }}.azurecr.io/${{ env.PHOTO_API_NAME }}:${{ env.VERSION }}-$SHA" >> $GITHUB_OUTPUT | |
echo "resizeApiImage: ${{ env.ACR_NAME }}.azurecr.io/${{ env.RESIZE_API_NAME }}:${{ env.VERSION }}-$SHA" | |
echo "resizeApiImage=${{ env.ACR_NAME }}.azurecr.io/${{ env.RESIZE_API_NAME }}:${{ env.VERSION }}-$SHA" >> $GITHUB_OUTPUT | |
build-photo-app-job: | |
runs-on: ubuntu-latest | |
needs: [get-vars-job] | |
steps: | |
- name: checkout-code | |
id: checkout-code | |
uses: actions/checkout@main | |
- name: login-azure | |
id: login-azure | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: acr-build-photo-api | |
id: acr-build-photo-api | |
uses: azure/cli@v2 | |
with: | |
azcliversion: 2.67.0 | |
inlineScript: | | |
az acr build \ | |
--registry ${{ needs.get-vars-job.outputs.acrName }} \ | |
-t "${{ needs.get-vars-job.outputs.photoApiImage }}" \ | |
--build-arg SERVICE_NAME=${{ env.PHOTO_API_NAME }} \ | |
--build-arg SERVICE_PORT=${{ env.PHOTO_API_PORT }} \ | |
-f ./Dockerfile . | |
build-resize-app-job: | |
runs-on: ubuntu-latest | |
needs: [get-vars-job] | |
steps: | |
- name: checkout-code | |
id: checkout-code | |
uses: actions/checkout@main | |
- name: login-azure | |
id: login-azure | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: acr-build-resize-api | |
id: acr-build-resize-api | |
uses: azure/cli@v2 | |
with: | |
azcliversion: 2.67.0 | |
inlineScript: | | |
az acr build \ | |
--registry ${{ needs.get-vars-job.outputs.acrName }} \ | |
-t "${{ needs.get-vars-job.outputs.resizeApiImage }}" \ | |
--build-arg SERVICE_NAME=${{ env.RESIZE_API_NAME }} \ | |
--build-arg SERVICE_PORT=${{ env.RESIZE_API_PORT }} \ | |
-f ./Dockerfile . | |
update-photo-app-job: | |
runs-on: ubuntu-latest | |
needs: [get-vars-job, build-photo-app-job] | |
env: | |
ACR_NAME: ${{ needs.get-vars-job.outputs.acrName }} | |
PHOTO_API_IMAGE: ${{ needs.get-vars-job.outputs.photoApiImage }} | |
steps: | |
- name: checkout-code | |
id: checkout-code | |
uses: actions/checkout@main | |
- name: login-azure | |
id: login-azure | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: deploy-photo-app | |
id: deploy-photo-app | |
uses: azure/cli@v2 | |
continue-on-error: false | |
with: | |
azcliversion: 2.67.0 | |
inlineScript: | | |
echo "updating container app: ${{ env.PHOTO_API_NAME }} in resource group ${{ needs.get-vars-job.outputs.rgName }}" | |
az containerapp update --name ${{ env.PHOTO_API_NAME }} --resource-group ${{ needs.get-vars-job.outputs.rgName }} --image ${{ env.PHOTO_API_IMAGE }} | |
update-resize-app-job: | |
runs-on: ubuntu-latest | |
needs: [get-vars-job, build-resize-app-job] | |
env: | |
ACR_NAME: ${{ needs.get-vars-job.outputs.acrName }} | |
RESIZE_API_IMAGE: ${{ needs.get-vars-job.outputs.resizeApiImage }} | |
steps: | |
- name: checkout-code | |
id: checkout-code | |
uses: actions/checkout@main | |
- name: login-azure | |
id: login-azure | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: deploy-resize-app | |
id: deploy-resize-app | |
uses: azure/cli@v2 | |
continue-on-error: false | |
with: | |
azcliversion: 2.67.0 | |
inlineScript: | | |
echo "updating container app: ${{ env.RESIZE_API_NAME }} in resource group ${{ needs.get-vars-job.outputs.rgName }}" | |
az containerapp update --name ${{ env.RESIZE_API_NAME }} --resource-group ${{ needs.get-vars-job.outputs.rgName}} --image ${{ env.RESIZE_API_IMAGE }} |