diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index 02108cb..65248a2 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -2,33 +2,40 @@ name: Backend CI/CD on: push: - branches: [ "main" ] + branches: + - main + +env: + AZURE_WEBAPP_NAME: hutopy-backend-api + AZURE_WEBAPP_PACKAGE_PATH: '.' + DOTNET_VERSION: '8.0.x' jobs: build_and_deploy: - runs-on: windows-latest + runs-on: ubuntu-latest + environment: dev steps: + + # Checkout the repository - uses: actions/checkout@v2 - - name: Setup .NET + + # Setup .NET Core + - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: '8.0.x' - - name: Restore dependencies + dotnet-version: ${{ env.DOTNET_VERSION }} + + # Run dotnet build and publish + - name: dotnet build and publish run: | - cd backend dotnet restore - - name: Build - run: | - cd backend dotnet build --configuration Release - - name: Publish - run: | - cd backend - dotnet publish --configuration Release --output ./publish + dotnet publish --configuration Release --output '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/backend-app' + + # Deploy to Azure WebApp - name: Deploy to Azure WebApp uses: azure/webapps-deploy@v2 with: - app-name: "" - slot-name: "production" # if using deployment slots + app-name: ${{ env.AZURE_WEBAPP_NAME }} publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} - package: ./backend/publish + package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/backend-app'