forked from shivaaws69/Wisdom-School-Spring-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (37 loc) · 1.36 KB
/
docker-image.yml
File metadata and controls
47 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: Push Docker Image to Google Artifact Registry
on:
push:
branches:
- master # Trigger on push to the master branch
jobs:
push-to-artifact-registry:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Checkout repository
uses: actions/checkout@v3
# Step 2: Set up JDK (for Maven)
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin' # You can choose the desired JDK distribution
# Step 3: Build the project using Maven
- name: Build with Maven
run: mvn clean package
# Step 4: Authenticate with Google Cloud
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
# Step 5: Configure Docker for Artifact Registry
- name: Configure Docker for Google Artifact Registry
run: gcloud auth configure-docker asia-docker.pkg.dev
# Step 6: Build the Docker image
- name: Build Docker image
run: |
docker build -t asia-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/school/sch:white .
# Step 7: Push the Docker image
- name: Push Docker image
run: |
docker push asia-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/school/sch:white