felipementel is testing out Azure Web App GitHub Actions π #11
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: Web App CI/CD | |
run-name: ${{ github.actor }} is testing out Azure Web App GitHub Actions π | |
on: | |
push: | |
branches: | |
- main | |
- '!feature/**' | |
paths: | |
- 'src/AzureWebApp/**' | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: 'Log level' | |
required: true | |
default: 'warning' | |
type: choice | |
options: | |
- info | |
- warning | |
- debug | |
pull_request: | |
branches: | |
- main | |
- '!feature/**' | |
paths: | |
- 'src/AzureWebApp/**' | |
env: | |
imageName: apim-food-app | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
dotnet-version: ['7.0.x', '8.0.x'] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: false | |
steps: | |
- run: echo "Azure Web App - $GITHUB_WORKSPACE" | |
- uses: actions/checkout@v4 | |
- name: Setup dotnet ${{ matrix.dotnet-version }} | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ matrix.dotnet-version }} | |
- name: Display dotnet version | |
run: dotnet --version | |
- name: Install dependencies | |
run: dotnet restore src/AzureWebApp/DEPLOY.FoodApp.API/DEPLOY.FoodApp.API.csproj | |
- name: Build and push Docker image | |
uses: docker/[email protected] | |
with: | |
registry: docker.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.REGISTRY_PASSWORD }} | |
- name: Get-Version from csproj | |
id: get-version | |
shell: bash | |
run: | | |
version=$(sed -n 's/.*<Version>\(.*\)<\/Version>.*/\1/p' ./src/AzureWebApp/DEPLOY.FoodApp.API/DEPLOY.FoodApp.API.csproj) | |
echo "tag=$version" >> "$GITHUB_OUTPUT" | |
- name: Build and push Docker image | |
run: | | |
docker buildx build -f ./src/AzureWebApp/DEPLOY.FoodApp.API/Dockerfile -t ${{ github.actor }}/${{ env.imageName }}:${{ steps.get-version.outputs.tag }} ./src/AzureWebApp | |
docker tag ${{ github.actor }}/${{ env.imageName }}:${{ steps.get-version.outputs.tag }} ${{ github.actor }}/${{ env.imageName }}:latest | |
docker push ${{ github.actor }}/${{ env.imageName }}:${{ steps.get-version.outputs.tag }} | |
docker push ${{ github.actor }}/${{ env.imageName }}:latest | |
deploy: | |
if: ${{ github.event_name != 'pull_request' }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Log in to Azure | |
uses: azure/[email protected] | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
# - name: Deploy to Azure Web App | |
# uses: azure/webapps-deploy@v2 | |
# with: | |
# app-name: ${{ secrets.WEBAPP_NAME }} | |
# slot-name: ${{ secrets.WEBAPP_SLOT_NAME }} | |
# publish-profile: ${{ secrets.WEBAPP_PUBLISH_PROFILE }} | |
# package: ${{ github.actor }}/${{ env.imageName }}:${{ steps.get-version.outputs.tag }} |