Skip to content

Commit 10d0e78

Browse files
committed
Add GitHub Actions workflow for building and pushing PHP Parser to ACR
1 parent c8a64b4 commit 10d0e78

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build and Push PHP Parser to ACR
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
env:
9+
AZURE_CONTAINER_REGISTRY: "prodsnorkellacr"
10+
CONTAINER_NAME: "php-parser"
11+
RESOURCE_GROUP: "prod-snorkell-backend-rg"
12+
13+
jobs:
14+
build-and-push:
15+
permissions:
16+
contents: read
17+
id-token: write
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- name: Azure Login
23+
uses: azure/login@v1.4.6
24+
with:
25+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
26+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
27+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
28+
29+
- name: Get ACR Credentials
30+
run: |
31+
az acr update -n ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.RESOURCE_GROUP }} --admin-enabled true
32+
ACR_USERNAME=$(az acr credential show -g ${{ env.RESOURCE_GROUP }} -n ${{ env.AZURE_CONTAINER_REGISTRY }} --query username -o tsv)
33+
ACR_PASSWORD=$(az acr credential show -g ${{ env.RESOURCE_GROUP }} -n ${{ env.AZURE_CONTAINER_REGISTRY }} --query passwords[0].value -o tsv)
34+
echo "::add-mask::$ACR_PASSWORD"
35+
echo "acr_username=$ACR_USERNAME" >> $GITHUB_ENV
36+
echo "acr_password=$ACR_PASSWORD" >> $GITHUB_ENV
37+
id: get-acr-creds
38+
39+
- uses: azure/docker-login@v1
40+
with:
41+
login-server: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io
42+
username: ${{ env.acr_username }}
43+
password: ${{ env.acr_password }}
44+
45+
- name: Build and Push Docker Image
46+
run: |
47+
docker build . -f Dockerfile -t ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:latest
48+
docker push ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:latest

0 commit comments

Comments
 (0)