diff --git a/.github/workflows/prod_workflow.yaml b/.github/workflows/prod_workflow.yaml new file mode 100644 index 0000000..bd88372 --- /dev/null +++ b/.github/workflows/prod_workflow.yaml @@ -0,0 +1,38 @@ +on: + pull_request: + branches: [main] + types: + - closed + workflow_dispatch: + +jobs: + Build: + environment: Production + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true + steps: + - uses: actions/checkout@v2 + - uses: azure/docker-login@v1 + with: + login-server: ${{ secrets.REGISTRY_DOMAIN }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + - name: Publish image to Azure Registry + run: | + docker build -t ${{ secrets.REGISTRY_DOMAIN }}/${{ secrets.REGISTRY_REPO }}:${{ github.sha }} -t ${{ secrets.REGISTRY_DOMAIN }}/${{ secrets.REGISTRY_REPO }}:${{ github.ref_name == 'main' && 'prod' || github.ref_name }}${{ github.ref_name != 'main' && '-latest' || 'latest' }} . + docker push ${{ secrets.REGISTRY_DOMAIN }}/${{ secrets.REGISTRY_REPO }} --all-tags + Deploy: + needs: Build + environment: + name: Production + runs-on: ubuntu-latest + steps: + - name: Login to Azure + uses: azure/login@v2.0.0 + with: + creds: ${{secrets.TDEI_CORE_AZURE_CREDS}} + - name: Deploy to Production + uses: azure/webapps-deploy@v2 + with: + app-name: ${{ secrets.AZURE_WEBAPP_NAME }} + images: ${{ secrets.REGISTRY_DOMAIN }}/${{ secrets.REGISTRY_REPO }}:${{ github.sha }}