Add GitHub Actions workflow for building and pushing PHP Parser to ACR #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push PHP Parser to ACR | |
| on: | |
| push: | |
| branches: ["main"] | |
| workflow_dispatch: | |
| env: | |
| AZURE_CONTAINER_REGISTRY: "prodsnorkellacr" | |
| CONTAINER_NAME: "php-parser" | |
| RESOURCE_GROUP: "prod-snorkell-backend-rg" | |
| jobs: | |
| build-and-push: | |
| permissions: | |
| contents: read | |
| id-token: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Azure Login | |
| uses: azure/[email protected] | |
| with: | |
| client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
| tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
| subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
| - name: Get ACR Credentials | |
| run: | | |
| az acr update -n ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.RESOURCE_GROUP }} --admin-enabled true | |
| ACR_USERNAME=$(az acr credential show -g ${{ env.RESOURCE_GROUP }} -n ${{ env.AZURE_CONTAINER_REGISTRY }} --query username -o tsv) | |
| ACR_PASSWORD=$(az acr credential show -g ${{ env.RESOURCE_GROUP }} -n ${{ env.AZURE_CONTAINER_REGISTRY }} --query passwords[0].value -o tsv) | |
| echo "::add-mask::$ACR_PASSWORD" | |
| echo "acr_username=$ACR_USERNAME" >> $GITHUB_ENV | |
| echo "acr_password=$ACR_PASSWORD" >> $GITHUB_ENV | |
| id: get-acr-creds | |
| - uses: azure/docker-login@v1 | |
| with: | |
| login-server: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io | |
| username: ${{ env.acr_username }} | |
| password: ${{ env.acr_password }} | |
| - name: Build and Push Docker Image | |
| run: | | |
| docker build . -f Dockerfile -t ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:latest | |
| docker push ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:latest |