-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (36 loc) · 1.51 KB
/
docker-BuildAndPush.yaml
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
name: Build and Push Docker images to Google Artifact Registry (GAR)
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GCP
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.OPS_ARTIFACT_REGISTRY_SVC_ACCOUNT }}
- name: Configure Docker to use the Google Artifact Registry
run: gcloud auth configure-docker us-central1-docker.pkg.dev
- name: Build and Push Docker Images
run: |
docker build -t us-central1-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/ops_terra_utils_slim:$GITHUB_SHA -f ./ops_docker_utils_slim/Dockerfile .
docker push us-central1-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/ops_terra_utils_slim:$GITHUB_SHA
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
REPOSITORY: ${{ secrets.ARTIFACT_REPO }}
GITHUB_SHA: ${{ github.sha }}
- name: Set image tag to 'latest'
run: |
docker tag us-central1-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/ops_terra_utils_slim:$GITHUB_SHA us-central1-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/ops_terra_utils_slim:latest
docker push us-central1-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/ops_terra_utils_slim:latest
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
REPOSITORY: ${{ secrets.ARTIFACT_REPO }}
GITHUB_SHA: ${{ github.sha }}