GitHub Actions Workshop

Master GitHub Actions with hands-on labs and exercises. Learn how to automate workflows, run tests, deploy applications, and more using GitHub's powerful automation platform. This repository has everything you need to get started with continuous integration and continuous deployment.


Project maintained by prasadhonrao Hosted on GitHub Pages — Theme by mattgraham

Solution: ASP.NET Web App Deploy to Azure

name: ASP.NET Web App Deploy to Azure
on:
  push:
    paths:
      - '.github/workflows/aspnet-webapp-deploy.yml'
      - 'src/dotnet/WebApp/**'

env:
  AZURE_WEBAPP_NAME: github-actions-workshop-aspnet-webapp
  AZURE_WEBAPP_PACKAGE_PATH: ./published
  CONFIGURATION: Release
  DOTNET_CORE_VERSION: 8.0.x
  WORKING_DIRECTORY: 'src/dotnet/WebApp'
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Setup .NET SDK
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: $
      - name: Verify Working Directory
        run: |
          echo "Current Directory: $(pwd)"
          ls $
      - name: Restore dependencies
        run: dotnet restore $
      - name: Build
        run: dotnet build "$" --configuration $ --no-restore
      - name: Publish
        run: dotnet publish "$" --configuration $ --output "$"
      - name: Publish Artifacts
        uses: actions/upload-artifact@v4
        with:
          name: webapp
          path: $
  deploy:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v4
        with:
          name: webapp
          path: $
      - name: Azure Login
        uses: azure/login@v2
        with:
          creds: $
      - name: Deploy to Azure WebApp
        uses: azure/webapps-deploy@v2
        with:
          app-name: $
          package: $