Scenario: Use Github Actions for continuous integration and deploy to Azure
Solution:
Per Github:
GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.
- Under .github folder -> create "workflows" -> Create file build-and-deploy.yml
- Azure -> App Service -> Get Publish Profile -> Download file -> Copy content
- Githib -> repository -> Actions-> Secrets -> New Repository Secret [AZURE_WEBAPP_PUBLISH_PROFILE] -> Value from #3
- build-and-deploy.yml
name: Build and Deploy
'on':
- push
- workflow_dispatch
env:
AZURE_WEBAPP_NAME: MyApp
AZURE_WEBAPP_PACKAGE_PATH: ./published
NETCORE_VERSION: '6.0'
jobs:
build:
name: Build and Deploy
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: 'Setup .NET Core SDK ${{ env.NETCORE_VERSION }}'
uses: actions/setup-dotnet@v1
with:
dotnet-version: '${{ env.NETCORE_VERSION }}'
- name: Restore packages
run: dotnet restore
- name: Build app
run: dotnet build --configuration Release --no-restore
- name: Test app
run: dotnet test --no-build
- name: Publish app for deploy
run: >-
dotnet publish --configuration Release --no-build --output ${{
env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: Deploy to Azure WebApp
uses: azure/webapps-deploy@v1
with:
app-name: '${{ env.AZURE_WEBAPP_NAME }}'
publish-profile: '${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}'
package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}'
- name: Publish Artifacts
uses: actions/upload-artifact@v1.0.0
with:
name: webapp
path: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}' |
No comments:
Post a Comment