Skip to content

Commit 3223d3c

Browse files
committed
push to gcp
1 parent 9371cc7 commit 3223d3c

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

.github/workflows/docker-build-push.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ on:
55
branches: [main]
66

77
env:
8-
REGISTRY: ghcr.io
9-
IMAGE_NAME: ${{ github.repository }}/core
8+
GITHUB_REGISTRY: ghcr.io
9+
GITHUB_IMAGE_NAME: ${{ github.repository }}/core
10+
GCP_REGISTRY: europe-west4-docker.pkg.dev
11+
GCP_PROJECT_ID: nanoapi-registry
12+
GCP_REPOSITORY: nanoapi-registry
13+
GCP_IMAGE_NAME: stackcore
1014

1115
jobs:
1216
build-and-push:
@@ -29,19 +33,42 @@ jobs:
2933
cd packages/core
3034
deno task build
3135
32-
- name: Log in to Container Registry
36+
# GitHub Container Registry login
37+
- name: Log in to GitHub Container Registry
3338
uses: docker/login-action@v3
3439
with:
35-
registry: ${{ env.REGISTRY }}
40+
registry: ${{ env.GITHUB_REGISTRY }}
3641
username: ${{ github.actor }}
3742
password: ${{ secrets.GITHUB_TOKEN }}
3843

44+
# GCP Authentication
45+
- name: Authenticate to Google Cloud
46+
uses: google-github-actions/auth@v2
47+
with:
48+
credentials_json: ${{ secrets.GCP_SA_KEY }}
49+
50+
# Configure Docker for GCP
51+
- name: Configure Docker for GCP Artifact Registry
52+
run: gcloud auth configure-docker ${{ env.GCP_REGISTRY }}
53+
54+
# Build and push to both registries
3955
- name: Build and push Docker image
4056
uses: docker/build-push-action@v5
4157
with:
4258
context: packages/core
4359
file: packages/core/Dockerfile
4460
push: true
4561
tags: |
46-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
47-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
62+
${{ env.GITHUB_REGISTRY }}/${{ env.GITHUB_IMAGE_NAME }}:${{ github.ref_name }}
63+
${{ env.GITHUB_REGISTRY }}/${{ env.GITHUB_IMAGE_NAME }}:${{ github.sha }}
64+
${{ env.GCP_REGISTRY }}/${{ env.GCP_PROJECT_ID }}/${{ env.GCP_REPOSITORY }}/${{ env.GCP_IMAGE_NAME }}:${{ github.ref_name }}
65+
${{ env.GCP_REGISTRY }}/${{ env.GCP_PROJECT_ID }}/${{ env.GCP_REPOSITORY }}/${{ env.GCP_IMAGE_NAME }}:${{ github.sha }}
66+
67+
# Output the image URLs for easy reference
68+
- name: Output image URLs
69+
run: |
70+
echo "Images pushed to:"
71+
echo "GitHub: ${{ env.GITHUB_REGISTRY }}/${{ env.GITHUB_IMAGE_NAME }}:${{ github.ref_name }}"
72+
echo "GitHub: ${{ env.GITHUB_REGISTRY }}/${{ env.GITHUB_IMAGE_NAME }}:${{ github.sha }}"
73+
echo "GCP: ${{ env.GCP_REGISTRY }}/${{ env.GCP_PROJECT_ID }}/${{ env.GCP_REPOSITORY }}/${{ env.GCP_IMAGE_NAME }}:${{ github.ref_name }}"
74+
echo "GCP: ${{ env.GCP_REGISTRY }}/${{ env.GCP_PROJECT_ID }}/${{ env.GCP_REPOSITORY }}/${{ env.GCP_IMAGE_NAME }}:${{ github.sha }}"

0 commit comments

Comments
 (0)