Skip to content

Instantly share code, notes, and snippets.

@seesharprun
Last active April 6, 2022 16:45
Show Gist options
  • Save seesharprun/2fe4759ea4cd683b28487d2620134708 to your computer and use it in GitHub Desktop.
Save seesharprun/2fe4759ea4cd683b28487d2620134708 to your computer and use it in GitHub Desktop.
Authoring DevOps pipelines using YAML in GitHub Actions

Demos

https://aka.ms/automategithubworkflow3.30

Automate .NET app

az login

az group create --name <resource-group-name> --location eastus
az appservice plan create --name <plan-name> --resource-group <resource-group-name> --is-linux
az webapp create --name <app-name> --plan <plan-name> --resource-group <resource-group-name> --runtime DOTNET:6.0

az webapp up --name <app-name> --plan <plan-name> --os-type linux --runtime DOTNET:6.0

az ad sp create-for-rbac --name <aad-app-name> --sdk-auth --role contributor --scopes /subscriptions/<subscription-id>/resourceGroups/<resource-group>
name: .NET CI
on: push
jobs:
  build-job:
    name: Build .NET assets
    runs-on: ubuntu-latest
    container: mcr.microsoft.com/dotnet/sdk:6.0
    steps:
      - run: dotnet --version
        name: Check .NET version
      - uses: actions/checkout@v2
        name: Checkout code
      - run: |
          dotnet publish \
          --configuration Release \
          --output out
        name: Publish .NET web application
      - name: Upload published app
        uses: actions/upload-artifact@v2
        with:
          name: web-app
          path: out/
  push-azure-job:
    name: Publish to Azure
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        name: Checkout code
      - uses: azure/login@v1
        with:
          creds: ${{ secrets.AZURE_CREDENTIALS }}
      - run: |
          az account show
        name: Show account details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment