Github Actions for continuous integration to Azure

       

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.

  1. Under .github folder -> create "workflows" -> Create file build-and-deploy.yml
  2.  Azure -> App Service -> Get Publish Profile -> Download file -> Copy content 
  3.  Githib -> repository -> Actions-> Secrets -> New Repository Secret [AZURE_WEBAPP_PUBLISH_PROFILE] -> Value from #3
  4. build-and-deploy.yml
  5.  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

Move Github Sub Repository back to main repo

 -- delete .gitmodules git rm --cached MyProject/Core git commit -m 'Remove myproject_core submodule' rm -rf MyProject/Core git remo...