Update and rename main_fefezfezf.yml to Build-deploy-code-docker.yml #1
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
| name: Docker & .NET App CI/CD | ||
| on: | ||
| workflow_dispatch: | ||
| env: | ||
| EXPECTED_RESPONSE: "Hello World!" | ||
| AZURE_WEBAPP_PACKAGE_PATH: ./publish | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v3 | ||
| with: | ||
| dotnet-version: 8.0.x | ||
| - name: Restore dependencies | ||
| run: dotnet restore | ||
| - name: Build | ||
| run: dotnet build --configuration Release --no-restore | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v3 | ||
| with: | ||
| dotnet-version: 8.0.x | ||
| - name: Restore dependencies | ||
| run: dotnet restore | ||
| - name: Run tests | ||
| run: dotnet test | ||
| build-docker: | ||
| runs-on: ubuntu-latest | ||
| needs: [build, test] | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v2 | ||
| - name: Log in to registry | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| registry: https://index.docker.io/v1/ | ||
| username: ${{ secrets.AzureAppService_ContainerUsername_007dc16c00194a579ee0e182f3912414 }} | ||
| password: ${{ secrets.AzureAppService_ContainerPassword_03b591a7c15d426aa4439cb5a79e30b8 }} | ||
| - name: Build and push container image to registry | ||
| uses: docker/build-push-action@v3 | ||
| with: | ||
| push: true | ||
| tags: forsanta/webapi-starter-dotnet8:${{ github.sha }} | ||
| file: ./Dockerfile | ||
| build-binary: | ||
| needs: [build, test] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v3 | ||
| with: | ||
| dotnet-version: 8.0.x | ||
| - name: Restore dependencies | ||
| run: dotnet restore | ||
| - name: Build | ||
| run: dotnet build --configuration Release --no-restore | ||
| - name: Publish app | ||
| run: dotnet publish -c Release -o publish | ||
| - name: Upload build artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: dotnet-publish | ||
| path: publish/ | ||
| deploy-binary: | ||
| permissions: | ||
| contents: none | ||
| runs-on: ubuntu-latest | ||
| needs: build-binary | ||
| environment: | ||
| name: 'Development' | ||
| outputs: | ||
| webapp-url: ${{ steps.set-url.outputs.webapp-url }} | ||
| steps: | ||
| - name: Download artifact from build job | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: dotnet-publish | ||
| path: ./publish | ||
| - name: Deploy to Azure Web App | ||
| id: deploy-to-webapp | ||
| uses: azure/webapps-deploy@v2 | ||
| with: | ||
| app-name: app-as-code | ||
| publish-profi | ||