Skip to content

Commit e72d8b7

Browse files
authored
Create main.yml
To create a GitHub Action that builds the WebApp.Dockerfile and pushes it to an Azure Container Registry when a PR is approved.
1 parent 643070f commit e72d8b7

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

.github/workflows/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
workflow_dispatch: # Add this line to enable manual triggering
9+
10+
jobs:
11+
build-and-push:
12+
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v2
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v1
21+
22+
- name: Log in to Azure Container Registry
23+
uses: azure/docker-login@v1
24+
with:
25+
login-server: ${{ secrets.ACR_LOGIN_SERVER }}
26+
username: ${{ secrets.ACR_USERNAME }}
27+
password: ${{ secrets.ACR_PASSWORD }}
28+
29+
- name: Build and push Docker image
30+
run: |
31+
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest -f WebApp.Dockerfile .
32+
docker push ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest

0 commit comments

Comments
 (0)