docker: use metadata-action for tags and labels
https://github.com/docker/metadata-action Packages on GitHub lack description since labels from Dockerfile are not used: https://github.com/vogler/free-games-claimer/pkgs/container/free-games-claimer/421753259
This commit is contained in:
parent
2bd12a986e
commit
ada40d05ec
2 changed files with 37 additions and 16 deletions
41
.github/workflows/docker.yml
vendored
41
.github/workflows/docker.yml
vendored
|
|
@ -34,15 +34,25 @@ jobs:
|
||||||
echo "IMAGE_TAG=$BRANCH" >> "$GITHUB_ENV"
|
echo "IMAGE_TAG=$BRANCH" >> "$GITHUB_ENV"
|
||||||
fi
|
fi
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Extract metadata for Docker (tags, labels)
|
||||||
uses: docker/setup-qemu-action@v3
|
id: meta
|
||||||
-
|
uses: docker/metadata-action@v5
|
||||||
name: Set up Docker Buildx
|
with:
|
||||||
uses: docker/setup-buildx-action@v3
|
images: |
|
||||||
|
${{ secrets.DOCKERHUB_USERNAME }}/free-games-claimer
|
||||||
|
ghcr.io/${{ github.actor }}/free-games-claimer
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
# use docker tag 'latest' for the default branch (default is to only use it for the latest git tag)
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}}
|
||||||
-
|
-
|
||||||
name: Login to Docker Hub
|
name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
# if: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }} # does not work: Unrecognized named-value: 'secrets' - https://www.cloudtruth.com/blog/skipping-jobs-in-github-actions-when-secrets-are-unavailable-securely-inject-configuration-secrets-into-github
|
# if: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }} # does not work: Unrecognized named-value: 'secrets' - https://www.cloudtruth.com/blog/skipping-jobs-in-github-actions-when-secrets-are-unavailable-securely-inject-configuration-secrets-into-github
|
||||||
|
if: github.event_name != 'pull_request' # don't try to login since PRs don't have access to secrets and need to set them in their fork
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
@ -53,20 +63,31 @@ jobs:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }} # actor is user that opened PR, was repository_owner before
|
username: ${{ github.actor }} # actor is user that opened PR, was repository_owner before
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
if: ${{ env.IMAGE_TAG != '' }}
|
if: ${{ env.IMAGE_TAG != '' }}
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ secrets.DOCKERHUB_USERNAME != '' }}
|
# push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
push: ${{ secrets.DOCKERHUB_USERNAME != '' }} # here we can access secrets
|
||||||
|
# TODO speed up by building in parallel? https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
build-args: |
|
build-args: |
|
||||||
COMMIT=${{ github.sha }}
|
COMMIT=${{ github.sha }}
|
||||||
BRANCH=${{ env.BRANCH }}
|
BRANCH=${{ env.BRANCH }}
|
||||||
NOW=${{ env.NOW }}
|
NOW=${{ env.NOW }}
|
||||||
platforms: linux/amd64,linux/arm64
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
tags: |
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
${{ secrets.DOCKERHUB_USERNAME }}/free-games-claimer:${{env.IMAGE_TAG}}
|
annotations: ${{ steps.meta.outputs.annotations }}
|
||||||
ghcr.io/${{ github.actor }}/free-games-claimer:${{env.IMAGE_TAG}}
|
# tags: |
|
||||||
|
# ${{ secrets.DOCKERHUB_USERNAME }}/free-games-claimer:${{env.IMAGE_TAG}}
|
||||||
|
# ghcr.io/${{ github.actor }}/free-games-claimer:${{env.IMAGE_TAG}}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
|
||||||
12
Dockerfile
12
Dockerfile
|
|
@ -75,14 +75,14 @@ ENV BRANCH=${BRANCH}
|
||||||
ENV NOW=${NOW}
|
ENV NOW=${NOW}
|
||||||
|
|
||||||
LABEL org.opencontainers.image.title="free-games-claimer" \
|
LABEL org.opencontainers.image.title="free-games-claimer" \
|
||||||
org.opencontainers.image.name="free-games-claimer" \
|
# org.opencontainers.image.name="free-games-claimer" \
|
||||||
org.opencontainers.image.description="Automatically claims free games on the Epic Games Store, Amazon Prime Gaming and GOG" \
|
org.opencontainers.image.description="Automatically claims free games on the Epic Games Store, Amazon Prime Gaming and GOG" \
|
||||||
org.opencontainers.image.url="https://github.com/vogler/free-games-claimer" \
|
org.opencontainers.image.url="https://github.com/vogler/free-games-claimer" \
|
||||||
org.opencontainers.image.source="https://github.com/vogler/free-games-claimer" \
|
org.opencontainers.image.source="https://github.com/vogler/free-games-claimer"
|
||||||
org.opencontainers.image.revision=${COMMIT} \
|
# org.opencontainers.image.revision=${COMMIT} \
|
||||||
org.opencontainers.image.ref.name=${BRANCH} \
|
# org.opencontainers.image.ref.name=${BRANCH} \
|
||||||
org.opencontainers.image.base.name="ubuntu:jammy" \
|
# org.opencontainers.image.base.name="ubuntu:jammy" \
|
||||||
org.opencontainers.image.version="latest"
|
# org.opencontainers.image.version="latest"
|
||||||
|
|
||||||
# Configure VNC via environment variables:
|
# Configure VNC via environment variables:
|
||||||
ENV VNC_PORT 5900
|
ENV VNC_PORT 5900
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue