feat: push distribution images to GHCR

This addition enables pushing distribution images into GHCR.
This is in addition to the Docker Hub push which remains in place.

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
This commit is contained in:
Milos Gajdos 2023-10-25 11:37:01 +01:00
parent 03a778c1f5
commit 3831c8ccb4
No known key found for this signature in database

View file

@ -15,6 +15,7 @@ on:
env: env:
DOCKERHUB_SLUG: distribution/distribution DOCKERHUB_SLUG: distribution/distribution
GHCR_SLUG: ghcr.io/${{ github.repository }}
permissions: permissions:
contents: read # to fetch code (actions/checkout) contents: read # to fetch code (actions/checkout)
@ -50,6 +51,7 @@ jobs:
build: build:
permissions: permissions:
contents: write # to create GitHub release (softprops/action-gh-release) contents: write # to create GitHub release (softprops/action-gh-release)
packages: write # so we can push the image to GHCR
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: needs:
@ -67,6 +69,7 @@ jobs:
with: with:
images: | images: |
${{ env.DOCKERHUB_SLUG }} ${{ env.DOCKERHUB_SLUG }}
${{ env.GHCR_SLUG }}
### versioning strategy ### versioning strategy
### push semver tag v3.2.1 on main (default branch) ### push semver tag v3.2.1 on main (default branch)
# distribution/distribution:3.2.1 # distribution/distribution:3.2.1
@ -85,7 +88,7 @@ jobs:
type=edge type=edge
labels: | labels: |
org.opencontainers.image.title=Distribution org.opencontainers.image.title=Distribution
org.opencontainers.image.description=The toolkit to pack, ship, store, and deliver container content org.opencontainers.image.description=The toolkit to pack, ship, store, and distribute container content
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v2
@ -96,6 +99,16 @@ jobs:
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Log in to GitHub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- -
name: Build artifacts name: Build artifacts
uses: docker/bake-action@v2 uses: docker/bake-action@v2