Skip to content

Commit 23549ee

Browse files
authored
ci(docker): Publish to GCR in addition to GHCR (#122)
The production image will be deployed from our internal artifact registry. This sets up the publishing process for both registries. Also adds explicit permission blocks to all workflows and jobs to resolve two issues raised by code scanning.
1 parent e284d4b commit 23549ee

File tree

2 files changed

+53
-14
lines changed

2 files changed

+53
-14
lines changed

.github/workflows/build.yml

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010

1111
permissions:
1212
contents: read
13-
packages: write
1413

1514
jobs:
1615
build:
@@ -73,42 +72,80 @@ jobs:
7372
name: objectstore-${{ matrix.platform }}
7473
path: /tmp/objectstore-${{ matrix.platform }}.tar
7574

76-
assemble-image:
77-
name: Publish
75+
assemble-ghcr:
76+
name: Publish to GHCR
7877
runs-on: ubuntu-latest
7978
needs: [build]
8079

8180
# Intentionally never publish on pull requests
8281
if: ${{ github.event_name != 'pull_request' }}
8382

83+
permissions:
84+
packages: write
85+
86+
env:
87+
REGISTRY: ghcr.io/getsentry/objectstore
88+
8489
steps:
8590
- uses: actions/checkout@v4
8691

8792
- run: docker login --username '${{ github.actor }}' --password-stdin ghcr.io <<< "$GHCR_TOKEN"
8893
env:
8994
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9095

91-
- name: Download Images
96+
- &download
97+
name: Download Images
9298
uses: actions/download-artifact@v5
9399
with:
94100
pattern: objectstore-*
95101
path: /tmp
96102
merge-multiple: true
97103

98-
- name: Push to GitHub Container Registry
99-
env:
100-
REGISTRY: ghcr.io/getsentry/objectstore
101-
SHA_TAG: ${{ github.sha }}
104+
- &assemble
105+
name: Push to GitHub Container Registry
102106
run: |
103107
for PLATFORM in amd64 arm64; do
104108
docker load --input /tmp/objectstore-$PLATFORM.tar
105-
docker tag $PLATFORM $REGISTRY:$SHA_TAG-$PLATFORM
106-
docker push $REGISTRY:$SHA_TAG-$PLATFORM
109+
docker tag $PLATFORM $REGISTRY:${{ github.sha }}-$PLATFORM
110+
docker push $REGISTRY:${{ github.sha }}-$PLATFORM
107111
done
108112
109-
for TAG in $SHA_TAG latest; do
113+
for TAG in ${{ github.sha }} latest; do
110114
docker manifest create $REGISTRY:$TAG \
111-
--amend $REGISTRY:$SHA_TAG-amd64 \
112-
--amend $REGISTRY:$SHA_TAG-arm64
115+
--amend $REGISTRY:${{ github.sha }}-amd64 \
116+
--amend $REGISTRY:${{ github.sha }}-arm64
113117
docker manifest push $REGISTRY:$TAG
114118
done
119+
120+
assemble-gcr:
121+
name: Publish to GCR
122+
runs-on: ubuntu-latest
123+
needs: [build]
124+
125+
# Intentionally never publish on pull requests
126+
if: ${{ github.event_name != 'pull_request' }}
127+
128+
permissions:
129+
id-token: write
130+
131+
env:
132+
REGISTRY: us-central1-docker.pkg.dev/sentryio/objectstore/image
133+
134+
steps:
135+
- name: Google Auth
136+
id: auth
137+
uses: google-github-actions/auth@v3
138+
with:
139+
workload_identity_provider: projects/868781662168/locations/global/workloadIdentityPools/prod-github/providers/github-oidc-pool
140+
service_account: [email protected]
141+
142+
- name: "Set up Cloud SDK"
143+
uses: "google-github-actions/setup-gcloud@v3"
144+
with:
145+
version: ">= 390.0.0"
146+
147+
- name: Configure docker
148+
run: gcloud auth configure-docker us-central1-docker.pkg.dev
149+
150+
- *download
151+
- *assemble

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
env:
1212
CARGO_TERM_COLOR: always
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
lint:
1619
name: Lint
@@ -91,7 +94,6 @@ jobs:
9194
runs-on: ubuntu-latest
9295

9396
permissions:
94-
contents: read
9597
pages: write
9698
id-token: write
9799

0 commit comments

Comments
 (0)