diff --git a/.github/workflows/azure-container-webapp.yml b/.github/workflows/azure-container-webapp.yml new file mode 100644 index 0000000..191c28f --- /dev/null +++ b/.github/workflows/azure-container-webapp.yml @@ -0,0 +1,57 @@ +name: Build and deploy a container to an Azure Web App + +on: + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + permissions: + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 + + - name: Log in to GitHub container registry + uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 + with: + push: true + tags: ghcr.io/${{ github.repository }}:latest + + deploy: + permissions: + contents: none + runs-on: ubuntu-latest + needs: build + + steps: + - name: Login to Azure + uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3.1.0 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_115A4872F8584980B401EF4FEA955410 }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_2018B1D528CC44D2A72008BF3E5046DC }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_9F7CD9C72BE445C0821771E18D062A0C }} + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@02a81bead70021f5284939794bcec79c271ab383 # v3.0.8 + with: + app-name: 'CloneDevOpsTemplateDocker' + images: 'ghcr.io/${{ github.repository }}:latest'