Skip to content
Open
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
36 changes: 30 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ on:
type: string

env:
PUBLISH_IMAGE: |
${{ secrets.DOCKERHUB_USERNAME != '' &&
secrets.DOCKERHUB_TOKEN != '' &&
github.ref == 'refs/heads/mainline' }}
PUBLISH_IMAGE: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' && github.ref == 'refs/heads/mainline' }}
PUBLISH_ECR: ${{ secrets.AWS_ACCESS_KEY_ID != '' && secrets.AWS_SECRET_ACCESS_KEY != '' && github.ref == 'refs/heads/mainline' }}

defaults:
run:
Expand Down Expand Up @@ -121,8 +119,10 @@ jobs:
original_tags="${{ toJson(matrix.meta.entries[0].tags) }}"
docker_hub_tags=$(echo $original_tags | sed 's/valkey-container/${{ secrets.DOCKERHUB_ACCOUNT }}\/valkey/g'| sed 's/\[ *//; s/ *\]//; s/ //g')
ghcr_tags=$(echo $original_tags | sed 's/valkey-container/ghcr.io\/${{ github.repository_owner }}\/valkey/g'| sed 's/\[ *//; s/ *\]//; s/ //g')
ecr_tags=$(echo $original_tags | sed 's/valkey-container/public.ecr.aws\/${{ secrets.ECR_REPOSITORY_ALIAS }}\/valkey-test/g'| sed 's/\[ *//; s/ *\]//; s/ //g')
echo "docker_hub_tags=$docker_hub_tags" >> $GITHUB_OUTPUT
echo "ghcr_tags=$ghcr_tags" >> $GITHUB_OUTPUT
echo "ecr_tags=$ecr_tags" >> $GITHUB_OUTPUT

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -139,15 +139,28 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
# We would not log in anywhere where we are not pushing
# Don't log in if we are not pushing changes
if: env.PUBLISH_IMAGE
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Build and push
- name: Configure AWS credentials
if: env.PUBLISH_ECR == 'true'
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR Public Gallery
if: env.PUBLISH_ECR == 'true'
run: |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws

- name: Build and push to Docker Hub and Github Container Registry
uses: docker/build-push-action@v5
with:
file: ./${{ matrix.meta.entries[0].directory }}/Dockerfile
Expand All @@ -158,6 +171,17 @@ jobs:
provenance: false
load: false

- name: Build and push to Amazon ECR
if: env.PUBLISH_ECR == 'true'
uses: docker/build-push-action@v5
with:
file: ./${{ matrix.meta.entries[0].directory }}/Dockerfile
push: true
tags: ${{ steps.modify_tags.outputs.ecr_tags }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
provenance: false
load: false

update-dockerhub-description:
if: |
(github.event_name == 'push' &&
Expand Down