Skip to content

Commit 44f34dc

Browse files
feat(ci): Use github composite action to build and push images x2 (#5090)
Retry of #5075 This time, includes commit sha that includes getsentry/action-build-and-push-images#15. I believe I can check to see if CI image is published in merge queue before it is merged to avoid what happened in #5075
1 parent 0c3fb3d commit 44f34dc

File tree

1 file changed

+35
-59
lines changed

1 file changed

+35
-59
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ jobs:
445445
name: Build Docker Image
446446
runs-on: ubuntu-latest
447447

448+
permissions:
449+
contents: read
450+
packages: write
451+
448452
strategy:
449453
matrix:
450454
image_name: ${{ fromJson(needs.build-setup.outputs.image_names) }}
@@ -467,26 +471,28 @@ jobs:
467471

468472
- name: Build and push to ghcr.io
469473
if: "!github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]'"
470-
run: |
471-
docker login --username '${{ github.actor }}' --password '${{ secrets.GITHUB_TOKEN }}' ghcr.io
472-
473-
docker buildx build \
474-
--platform "${PLATFORMS}" \
475-
--tag "${DOCKER_IMAGE}:${REVISION}" \
476-
$( [[ "${IS_MASTER}" == "true" ]] && printf %s "--tag ${DOCKER_IMAGE}:nightly" ) \
477-
--file Dockerfile.release \
478-
--push \
479-
.
474+
uses: getsentry/action-build-and-push-images@4852d671d747d7c0268b2a3fc429fee9d4a16f78
475+
with:
476+
image_name: ${{ matrix.image_name }}
477+
platforms: ${{ env.PLATFORMS }}
478+
dockerfile_path: "./Dockerfile.release"
479+
ghcr: true
480+
tag_nightly: true
481+
tag_latest: true
482+
google_ar: false
483+
publish_on_pr: true
480484

481485
- name: Build and publish docker artifact
482486
if: "github.event.pull_request.head.repo.fork || github.actor == 'dependabot[bot]'"
483-
run: |
484-
docker buildx build \
485-
--platform "${PLATFORMS}" \
486-
--tag "${DOCKER_IMAGE}:${REVISION}" \
487-
--file Dockerfile.release \
488-
--output type=docker,dest=${{ matrix.image_name }}-docker-image \
489-
.
487+
uses: getsentry/action-build-and-push-images@4852d671d747d7c0268b2a3fc429fee9d4a16f78
488+
with:
489+
image_name: ${{ matrix.image_name }}
490+
platforms: ${{ env.PLATFORMS }}
491+
dockerfile_path: "./Dockerfile.release"
492+
ghcr: false
493+
google_ar: false
494+
outputs: "type=docker,dest=${{ matrix.image_name }}-docker-image"
495+
tags: "ghcr.io/getsentry/${{ matrix.image_name }}:${{ github.event.pull_request.head.sha || github.sha }}"
490496

491497
- name: Upload docker image
492498
if: "github.event.pull_request.head.repo.fork || github.actor == 'dependabot[bot]'"
@@ -553,48 +559,18 @@ jobs:
553559
done
554560
555561
- name: Build and push to Internal AR
556-
run: |
557-
docker buildx build \
558-
--platform "${PLATFORMS}" \
559-
--tag "${AR_DOCKER_IMAGE}:${REVISION}" \
560-
$( [[ "${IS_MASTER}" == "true" ]] && printf %s "--tag ${AR_DOCKER_IMAGE}:latest" ) \
561-
--file Dockerfile.release \
562-
--push \
563-
.
564-
565-
publish-to-dockerhub:
566-
needs: [build-setup, build-docker]
567-
568-
runs-on: ubuntu-22.04
569-
name: Publish Relay to DockerHub
570-
571-
strategy:
572-
matrix:
573-
image_name: ["relay"] # Don't publish relay-pop (for now)
574-
575-
if: github.event_name == 'merge_group'
576-
577-
env:
578-
GHCR_DOCKER_IMAGE: "ghcr.io/getsentry/${{ matrix.image_name }}"
579-
DH_DOCKER_IMAGE: "getsentry/${{ matrix.image_name }}"
580-
REVISION: "${{ github.event.pull_request.head.sha || github.sha }}"
581-
582-
steps:
583-
- name: Login to DockerHub
584-
run: docker login --username=sentrybuilder --password ${{ secrets.DOCKER_HUB_RW_TOKEN }}
585-
586-
- name: Copy Image from GHCR to DockerHub
587-
run: |
588-
# We push 3 tags to Dockerhub:
589-
# 1) the full sha of the commit
590-
docker buildx imagetools create --tag "${DH_DOCKER_IMAGE}:${REVISION}" "${GHCR_DOCKER_IMAGE}:${REVISION}"
591-
592-
# 2) the short sha
593-
SHORT_SHA=$(echo ${GITHUB_SHA} | cut -c1-8)
594-
docker buildx imagetools create --tag "${DH_DOCKER_IMAGE}:${SHORT_SHA}" "${GHCR_DOCKER_IMAGE}:${REVISION}"
595-
596-
# 3) nightly
597-
docker buildx imagetools create --tag "${DH_DOCKER_IMAGE}:nightly" "${GHCR_DOCKER_IMAGE}:${REVISION}"
562+
uses: getsentry/action-build-and-push-images@4852d671d747d7c0268b2a3fc429fee9d4a16f78
563+
with:
564+
image_name: ${{ matrix.image_name }}
565+
platforms: ${{ env.PLATFORMS }}
566+
dockerfile_path: "./Dockerfile.release"
567+
ghcr: false
568+
publish_on_pr: true
569+
tag_latest: true
570+
google_ar: true
571+
google_ar_image_name: ${{ env.AR_DOCKER_IMAGE }}
572+
google_workload_identity_provider: projects/868781662168/locations/global/workloadIdentityPools/prod-github/providers/github-oidc-pool
573+
google_service_account: [email protected]
598574

599575
publish-to-gcr:
600576
timeout-minutes: 5

0 commit comments

Comments
 (0)