Skip to content

Instantly share code, notes, and snippets.

@tcmorris
Created August 20, 2020 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcmorris/dada56a630316670a064882a2753f04f to your computer and use it in GitHub Desktop.
Save tcmorris/dada56a630316670a064882a2753f04f to your computer and use it in GitHub Desktop.
Example GitHub Action for building and deploying a .NET Core app to Azure.
name: Build and deploy to Azure
on: [push]
env:
PROJECT_DIR: yourapp/path
AZURE_WEBAPP_NAME: yourapp-name
DOTNET_VERSION: '2.2.402'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# Checkout the repo
- uses: actions/checkout@master
# Setup .NET Core SDK
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
# Run dotnet build and publish
- name: dotnet build and publish
run: |
cd ${{ env.PROJECT_DIR }}
dotnet build --configuration Release
dotnet publish -c Release -o publish
# Deploy to Azure Web apps
- name: 'Run Azure webapp deploy action using publish profile'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: '${{ env.PROJECT_DIR }}/publish'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment