Merge pull request #15 from ahmedsza/alert-autofix-1 #20
This file contains hidden or 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
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: .NET | |
on: | |
push: | |
branches: [ "main" ] | |
paths: | |
- 'src/Application/**' | |
pull_request: | |
branches: [ "main" ] | |
paths: | |
- 'src/Application/**' | |
workflow_dispatch: | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
registryName: "q3zpru2gmy754mpnpreg.azurecr.io" # Replace registryName with the name of your registry | |
repositoryName: "techexcel/dotnetcoreapp" | |
dockerFolderPath: "src/Application/src/RazorPagesTestSample" | |
tag: ${{ github.run_number }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: dotnet restore src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj | |
- name: Build | |
run: dotnet build src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj --no-restore | |
- name: Test | |
run: dotnet test src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj --no-build --verbosity normal | |
buildacr: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to Azure Container Registry | |
run: echo "${{ secrets.ACR_PASSWORD }}" | docker login ${{ env.registryName }} -u ${{ secrets.ACR_USERNAME }} --password-stdin | |
- name: Build and push Docker image | |
run: | | |
docker build ${{ env.dockerFolderPath }} -t ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} | |
docker push ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} | |
deploytodev: | |
runs-on: ubuntu-latest | |
needs: buildacr | |
environment: dev | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Azure Login | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Deploy to Azure Web App | |
run: | | |
az webapp config container set \ | |
--name q3zpru2gmy754-dev \ | |
--resource-group ${{ secrets.AZURE_RG }} \ | |
--docker-custom-image-name ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} \ | |
--docker-registry-server-url https://${{ env.registryName }} \ | |
--docker-registry-server-user ${{ secrets.ACR_USERNAME }} \ | |
--docker-registry-server-password ${{ secrets.ACR_PASSWORD }} | |
deploytotest: | |
runs-on: ubuntu-latest | |
needs: deploytodev | |
environment: test | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Azure Login | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Deploy to Azure Web App | |
run: | | |
az webapp config container set \ | |
--name q3zpru2gmy754-test \ | |
--resource-group ${{ secrets.AZURE_RG }} \ | |
--docker-custom-image-name ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} \ | |
--docker-registry-server-url https://${{ env.registryName }} \ | |
--docker-registry-server-user ${{ secrets.ACR_USERNAME }} \ | |
--docker-registry-server-password ${{ secrets.ACR_PASSWORD }} | |
deploytoprod: | |
runs-on: ubuntu-latest | |
needs: deploytotest | |
environment: prod | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Azure Login | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Deploy to Azure Web App | |
run: | | |
az webapp config container set \ | |
--name q3zpru2gmy754-prod \ | |
--resource-group ${{ secrets.AZURE_RG }} \ | |
--docker-custom-image-name ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} \ | |
--docker-registry-server-url https://${{ env.registryName }} \ | |
--docker-registry-server-user ${{ secrets.ACR_USERNAME }} \ | |
--docker-registry-server-password ${{ secrets.ACR_PASSWORD }} |