File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree File renamed without changes.
Original file line number Diff line number Diff line change 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 .
You can’t perform that action at this time.
0 commit comments