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

Push images to GitHub Container Registry in addition to DockerHub #90

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
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
24 changes: 20 additions & 4 deletions .ci-scripts/release/build-docker-images-on-release.bash
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,28 @@ set -o nounset
# Version: "1.0.0"
VERSION="${GITHUB_REF/refs\/tags\//}"

# Build and push :VERSION tag e.g. ponylang/ponyup:0.32.1
DOCKER_TAG=${GITHUB_REPOSITORY}:"${VERSION}"
## DockerHub

NAME="${GITHUB_REPOSITORY}"
# Build and push :VERSION tag e.g. ponylang/changelog-tool:0.32.1
DOCKER_TAG="${NAME}:${VERSION}"
docker build --pull -t "${DOCKER_TAG}" .
docker push "${DOCKER_TAG}"

# Build and push "release" tag e.g. ponylang/changelog-tool:release
DOCKER_TAG="${NAME}:release"
docker build --pull -t "${DOCKER_TAG}" .
docker push "${DOCKER_TAG}"

## GitHub Container Registry

NAME="ghcr.io/${GITHUB_REPOSITORY}"
# Build and push :VERSION tag e.g. ghcr.io/ponylang/changelog-tool:0.32.1
DOCKER_TAG="${NAME}:${VERSION}"
docker build --pull -t "${DOCKER_TAG}" .
docker push "${DOCKER_TAG}"

# Build and push "release" tag e.g. ponylang/ponyup:release
DOCKER_TAG=${GITHUB_REPOSITORY}:release
# Build and push "release" tag e.g. ghcr.io/ponylang/changelog-tool:release
DOCKER_TAG="${NAME}:release"
docker build --pull -t "${DOCKER_TAG}" .
docker push "${DOCKER_TAG}"
13 changes: 11 additions & 2 deletions .ci-scripts/release/build-latest-docker-images.bash
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ fi
# allow above so we can display nice error messages for expected unset variables
set -o nounset

# Build and push "latest" tag e.g. ponylang/ponyup:latest
DOCKER_TAG=${GITHUB_REPOSITORY}:latest
## DockerHub

# Build and push "latest" tag e.g. ponylang/changelog-tool:latest
DOCKER_TAG="${GITHUB_REPOSITORY}:latest"
docker build --pull -t "${DOCKER_TAG}" .
docker push "${DOCKER_TAG}"

## GitHub Container Registry

# Build and push "latest" tag e.g. ghcr.io/ponylang/changelog-tool:latest
DOCKER_TAG="ghcr.io/${GITHUB_REPOSITORY}:latest"
docker build --pull -t "${DOCKER_TAG}" .
docker push "${DOCKER_TAG}"
9 changes: 8 additions & 1 deletion .github/workflows/latest-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Docker login
- name: Login to DockerHub
run: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
- name: Login to GitHub Container Registry
# v2.2.0
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
run: bash .ci-scripts/release/build-latest-docker-images.bash
9 changes: 8 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,18 @@ jobs:
- pre-artefact-creation
steps:
- uses: actions/checkout@v3
- name: Docker login
- name: Login to DockerHub
run: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
- name: Login to GitHub Container Registry
# v2.2.0
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
run: bash .ci-scripts/release/build-docker-images-on-release.bash

Expand Down
Loading