Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additionally publish images to public.ecr.aws #319

Merged
merged 3 commits into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 45 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:

permissions:
contents: read
id-token: write

jobs:
shellcheck:
Expand Down Expand Up @@ -126,8 +127,18 @@ jobs:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Load Docker images into the Docker daemon
run: zstd -dc --long=31 images.tar.zst | docker load
- name: Log into Docker Hub
- name: Log in to Docker Hub
run: echo '${{ secrets.DOCKER_HUB_TOKEN }}' | docker login -u '${{ secrets.DOCKER_HUB_USERNAME }}' --password-stdin
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ECR_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
- name: Log in to Amazon ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Publish base images to registries
run: |
variants=("" "-build")
Expand All @@ -140,11 +151,12 @@ jobs:
for variant in "${variants[@]}"; do
srcTag="heroku/heroku:${{ matrix.stack-version}}${variant}"
destTag="${srcTag}${platformSuffix}${TAG_SUFFIX}"
docker tag "${srcTag}" "${destTag}"
docker push "${destTag}"
for host in "docker.io" "public.ecr.aws"; do
docker tag "${srcTag}" "${host}/${destTag}"
docker push "${host}/${destTag}"
done
done


publish-indices:
if: github.ref_name == 'main' || github.ref_type == 'tag'
name: "Publish heroku-${{ matrix.stack-version }} indices"
Expand All @@ -158,16 +170,28 @@ jobs:
matrix:
stack-version: ["24"]
steps:
- name: Log into Docker Hub
- name: Log in to Docker Hub
run: echo '${{ secrets.DOCKER_HUB_TOKEN }}' | docker login -u '${{ secrets.DOCKER_HUB_USERNAME }}' --password-stdin
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ECR_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
- name: Log in to Amazon ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Publish multi-arch image index
run: |
for variant in '' '-build'; do
indexTag="heroku/heroku:${{ matrix.stack-version }}${variant}${TAG_SUFFIX}"
armTag="heroku/heroku:${{ matrix.stack-version }}${variant}_linux-arm64${TAG_SUFFIX}"
amdTag="heroku/heroku:${{ matrix.stack-version }}${variant}_linux-amd64${TAG_SUFFIX}"
docker manifest create "$indexTag" "$amdTag" "$armTag"
docker manifest push "$indexTag"
for host in 'docker.io' 'public.ecr.aws'; do
docker manifest create "${host}/${indexTag}" "${host}/${amdTag}" "${host}/${armTag}"
docker manifest push "${host}/${indexTag}"
done
done

promote-tags:
Expand All @@ -184,8 +208,18 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log into Docker Hub
- name: Log in to Docker Hub
run: echo '${{ secrets.DOCKER_HUB_TOKEN }}' | docker login -u '${{ secrets.DOCKER_HUB_USERNAME }}' --password-stdin
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ secrets.AWS_ECR_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
- name: Log in to Amazon ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Install crane
uses: buildpacks/github-actions/[email protected]
- name: Promote images to stable tag
Expand All @@ -205,5 +239,7 @@ jobs:
fi
for destTag in "${destTags[@]}"; do
srcTag="${destTag}.${{ github.ref_name }}"
crane copy "${srcTag}" "${destTag}"
for host in "docker.io" "public.ecr.aws"; do
crane copy "${host}/${srcTag}" "${host}/${destTag}"
done
done