Skip to content

Commit f47945d

Browse files
Connected GHA to AR in GCP
1 parent c7ba25c commit f47945d

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed
Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,43 @@
1-
#This workflow automatically takes my code, builds a docker image, and returns the date and time
2-
#This is the name of the workflow - used under the Actions tab
1+
#This workflow automatically takes my code, builds a docker image, and returns the date and time, which can be validated in the logs
2+
#This is the name of this workflow
33
name: Go Dockerimage Pipeline
4-
#This is workflow name - will appear in the list of workflow runs
4+
#This is workflow name
55
run-name: CI/CD Pipeline
6-
#Trigger for the workflow - in otherwords, what causes the workflow to kick off
6+
#Trigger for the workflow
77
on:
88
push:
99
branches:
1010
- main
1111
#Groups all jobs associated with this workflow together
1212
jobs:
1313
build:
14-
#Specifies the type of VM to create and what OS it runs. Docker is already installed
14+
#Specifies the type of VM OS to run.
1515
runs-on: ubuntu-latest
16-
#Steps involved with the jobs the workflow runs
1716
steps:
1817
#Step1 - Checks out code
1918
- name: Checkout code
20-
#Most recent version of actions/checkout - checksout repo to the runner
19+
#Most recent version of actions/checkout - checksout repo to the runner
2120
uses: actions/checkout@v5
2221

23-
#Step2 - Setups up Docker
22+
#Step2 - Builds the Docker image with provided code
2423
- name: Docker
2524
run: docker build -t gotime .
2625

27-
#Step3 - Run your container
26+
#Step3 - Run the container then deletes it once the code has ran
2827
- name: Run container and capture output
2928
run: docker run --rm gotime
29+
30+
#Step4 - Authenticates to Google Cloud with the existing JSON key
31+
- name: Authenticate to Google Cloud
32+
uses: google-github-actions/auth@v3
33+
with:
34+
credentials_json: '${{ secrets.GCP_SA_KEY }}'
35+
36+
#Step5 - Configures Docker to access my GCP project
37+
- name: Configure Docker to access GCP project
38+
run: | gcloud auth configure-docker us-west1-docker.pkg.dev
39+
40+
#Step6 - Tags the container and pushes to the Artifact Repo in my GCP project
41+
- name: Push to Artifact Registry
42+
run: | docker tag gotime us-west1-docker.pkg.dev/YOUR_PROJECT/YOUR_REPO/gotime:latest
43+
docker push us-west1-docker.pkg.dev/YOUR_PROJECT/YOUR_REPO/gotime:latest

0 commit comments

Comments
 (0)