Skip to content

Commit 6861f48

Browse files
committed
GCP Workload Identity Federation and Github configuration done. Update the
1 parent 311f52a commit 6861f48

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/docker.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build and Push to Google Cloud
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
10+
ARTIFACT_REPO_NAME: europe-west4-docker.pkg.dev
11+
REPO_NAME: fastapi-docker-repo
12+
IMAGE_NAME: fastapi
13+
TAG: latest
14+
15+
jobs:
16+
build-and-push:
17+
name: Build and Push Docker Image
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Authenticate with GCP
25+
uses: 'google-github-actions/auth@v2'
26+
with:
27+
project_id: ${{ secrets.GCP_PROJECT_ID }}
28+
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
29+
service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
30+
31+
- name: Configure Docker to use Google Artifact Registry
32+
run: |
33+
gcloud auth configure-docker $ARTIFACT_REPO_NAME
34+
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v2
37+
38+
- name: Build and Push Docker image
39+
run: |
40+
docker buildx build \
41+
--push \
42+
--tag
43+
$ARTIFACT_REPO_NAME/$PROJECT_ID/$REPO_NAME/$IMAGE_NAME:$TAG .

0 commit comments

Comments
 (0)