Skip to content

Commit 5f7d979

Browse files
committed
Publish to GAR along with Dockerhub
1 parent 83b319e commit 5f7d979

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

.github/workflows/build-publish.yaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@ jobs:
1616
env:
1717
TEST_TAG: ${{ github.repository }}:test
1818
TEST_CONTAINER_NAME: jbi-healthcheck
19+
GAR_LOCATION: us
20+
GAR_REPOSITORY: jbi-prod
21+
GCP_PROJECT_ID: moz-fx-jbi-prod
22+
IMAGE: jbi
1923
steps:
2024
- name: Check out the repo
2125
uses: actions/checkout@v4
2226
with:
2327
fetch-depth: 0 # Fetch everything (tags)
28+
fetch-tags: true
29+
2430
- name: Set tag version
2531
run: echo "JBI_TAG=$(git describe --tags --abbrev=4)" >> $GITHUB_ENV
32+
2633
- name: Build `version.json` file
2734
run: |
2835
printf '{\n "commit": "%s",\n "version": "%s",\n "source": "%s",\n "build": "%s"\n}\n' \
@@ -35,27 +42,43 @@ jobs:
3542
id: meta
3643
uses: docker/metadata-action@v5
3744
with:
38-
images: ${{ github.repository }}
45+
images:
46+
${{ github.repository }}
47+
${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/${{ env.IMAGE }}
3948
# https://github.com/marketplace/actions/docker-metadata-action#tags-input
4049
tags: |
4150
type=semver,pattern={{raw}}
4251
type=raw,value=latest,enable={{is_default_branch}}
4352
type=sha,prefix=,enable={{is_default_branch}}
4453
54+
- id: gcp_auth
55+
name: Log into GCP
56+
uses: google-github-actions/auth@v2
57+
if: github.event_name != 'pull_request'
58+
with:
59+
token_format: access_token
60+
service_account: artifact-writer@${{ env.GCP_PROJECT_ID }}.iam.gserviceaccount.com
61+
workload_identity_provider: ${{ vars.GCPV2_GITHUB_WORKLOAD_IDENTITY_PROVIDER }}
62+
4563
- name: Login to Docker Hub
4664
if: github.event_name != 'pull_request'
4765
uses: docker/login-action@v3
4866
with:
4967
username: ${{ secrets.DOCKERHUB_USERNAME }}
5068
password: ${{ secrets.DOCKERHUB_TOKEN }}
5169

70+
- name: Set up Docker Buildx
71+
uses: docker/setup-buildx-action@v3
72+
5273
- name: Build and export to Docker
5374
uses: docker/build-push-action@v6
5475
with:
5576
context: .
5677
load: true
5778
push: false
5879
tags: ${{ env.TEST_TAG }}
80+
cache-from: type=gha
81+
cache-to: type=gha,mode=max
5982

6083
- name: Spin up container
6184
run: |
@@ -80,3 +103,5 @@ jobs:
80103
context: .
81104
push: ${{ github.event_name != 'pull_request' }}
82105
tags: ${{ steps.meta.outputs.tags }}
106+
cache-from: type=gha
107+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)