diff --git a/.github/workflows/farfalle-backend-AutoDeployTrigger-3e5a49cd-d51c-45b9-93a5-6170d843a4cc.yml b/.github/workflows/farfalle-backend-AutoDeployTrigger-3e5a49cd-d51c-45b9-93a5-6170d843a4cc.yml new file mode 100644 index 0000000..98443e4 --- /dev/null +++ b/.github/workflows/farfalle-backend-AutoDeployTrigger-3e5a49cd-d51c-45b9-93a5-6170d843a4cc.yml @@ -0,0 +1,48 @@ +name: Trigger auto deployment for farfalle-backend + +# When this action will be executed +on: + # Automatically trigger it when detected changes in repo + push: + branches: + [ main ] + paths: + - 'src/backend/**' + - '.github/workflows/farfalle-backend-AutoDeployTrigger-3e5a49cd-d51c-45b9-93a5-6170d843a4cc.yml' + + # Allow manual trigger + workflow_dispatch: + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + contents: read #Required when GH token is used to authenticate with private repo + + steps: + - name: Checkout to the branch + uses: actions/checkout@v2 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.FARFALLEBACKEND_AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.FARFALLEBACKEND_AZURE_TENANT_ID }} + subscription-id: ${{ secrets.FARFALLEBACKEND_AZURE_SUBSCRIPTION_ID }} + + - name: Build and push container image to registry + uses: azure/container-apps-deploy-action@v2 + with: + appSourcePath: ${{ github.workspace }} + dockerfilePath: ./src/backend/Dockerfile + registryUrl: farfallebackend.azurecr.io + registryUsername: ${{ secrets.FARFALLEBACKEND_REGISTRY_USERNAME }} + registryPassword: ${{ secrets.FARFALLEBACKEND_REGISTRY_PASSWORD }} + containerAppName: farfalle-backend + resourceGroup: DefaultResourceGroup-EUS + imageToBuild: farfallebackend.azurecr.io/farfalle-backend:${{ github.sha }} + _buildArgumentsKey_: | + _buildArgumentsValues_ + + diff --git a/.github/workflows/main_farfalle-backend.yml b/.github/workflows/main_farfalle-backend.yml deleted file mode 100644 index be53e17..0000000 --- a/.github/workflows/main_farfalle-backend.yml +++ /dev/null @@ -1,51 +0,0 @@ -# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy -# More GitHub Actions for Azure: https://github.com/Azure/actions - -name: Build and deploy container app to Azure Web App - farfalle-backend - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - build: - runs-on: 'ubuntu-latest' - - steps: - - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to registry - uses: docker/login-action@v2 - with: - registry: https://farfallebackend.azurecr.io/ - username: ${{ secrets.AzureAppService_ContainerUsername_abc14ec1783a4e46b2aaa3b71b6ff5f2 }} - password: ${{ secrets.AzureAppService_ContainerPassword_b441d7279c804257844cb8c32c699fac }} - - - name: Build and push container image to registry - uses: docker/build-push-action@v3 - with: - push: true - tags: farfallebackend.azurecr.io/${{ secrets.AzureAppService_ContainerUsername_abc14ec1783a4e46b2aaa3b71b6ff5f2 }}/farfalle-backend:${{ github.sha }} - file: ./src/backend/Dockerfile - - deploy: - runs-on: ubuntu-latest - needs: build - environment: - name: 'production' - url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} - - steps: - - name: Deploy to Azure Web App - id: deploy-to-webapp - uses: azure/webapps-deploy@v2 - with: - app-name: 'farfalle-backend' - slot-name: 'production' - publish-profile: ${{ secrets.AzureAppService_PublishProfile_8693fb95506746ad8d81ab75d836aec5 }} - images: 'farfallebackend.azurecr.io/${{ secrets.AzureAppService_ContainerUsername_abc14ec1783a4e46b2aaa3b71b6ff5f2 }}/farfalle-backend:${{ github.sha }}'