Skip to content
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
9 changes: 6 additions & 3 deletions .github/workflows/docker-description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- 'README.md'
- '.github/workflows/docker-description.yml'

env:
DOCKERHUB_REPO: 'maateen/docker-beanstalkd'

jobs:
docker-description:
runs-on: ubuntu-latest
Expand All @@ -15,10 +18,10 @@ jobs:
uses: actions/checkout@v4

- name: Update Docker Hub description
uses: peter-evans/dockerhub-description@v3
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: maateen/docker-beanstalkd
short-description: "A Docker container for Beanstalkd, a simple and fast general-purpose work queue."
repository: ${{ env.DOCKERHUB_REPO }}
short-description: ${{ github.event.repository.description }}
readme-filepath: ./README.md
128 changes: 22 additions & 106 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,165 +7,81 @@ on:
branches: [main]

env:
DOCKER_REPOSITORY: 'maateen/docker-beanstalkd'
GHCR_REPOSITORY: 'ghcr.io/maateen/docker-beanstalkd'
DOCKERHUB_REPO: maateen/docker-beanstalkd
GHCR_REPO: ghcr.io/maateen/docker-beanstalkd
PLATFORMS: linux/amd64,linux/arm64

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # Added permissions for GHCR
strategy:
fail-fast: false
matrix:
alpine_version: ["3.18", "3.19", "3.20", "3.21"]
beanstalkd_version: ["v1.8", "v1.9", "v1.10", "v1.11", "v1.12", "v1.13"]
platform: ["linux/amd64", "linux/arm64"]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Prepare
id: prep
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
echo "VERSION=${{ matrix.beanstalkd_version }}-alpine-${{ matrix.alpine_version }}" >> $GITHUB_ENV
echo "IS_RELEASE=${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') }}" >> $GITHUB_ENV
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKER_REPOSITORY }}
${{ env.GHCR_REPOSITORY }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
${{ env.DOCKERHUB_REPO }}
${{ env.GHCR_REPO }}

- name: Login to Docker Hub
if: env.IS_RELEASE == 'true'
uses: docker/login-action@v3
with:
username: ${{ github.repository_owner }}
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
if: env.IS_RELEASE == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push by digest
- name: Build and push
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ env.PLATFORMS }}
push: ${{ env.IS_RELEASE == 'true' }}
build-args: |
ALPINE_VERSION=${{ matrix.alpine_version }}
BEANSTALKD_VERSION=${{ matrix.beanstalkd_version }}
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
BUILD_DATE=${{ env.BUILD_DATE }}
VCS_REF=${{ github.sha }}
VERSION=${{ matrix.beanstalkd_version }}
context: .
labels: |
${{ steps.meta.outputs.labels }}
org.opencontainers.image.description=A Docker container for beanstalkd, a simple and fast general purpose work queue
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
platforms: ${{ matrix.platform }}
outputs: type=image,name=${{ env.DOCKER_REPOSITORY }},name=${{ env.GHCR_REPOSITORY }},push-by-digest=true,name-canonical=true,push=${{ env.IS_RELEASE == 'true' }}
VERSION=${{ env.VERSION }}
tags: |
${{ env.DOCKERHUB_REPO }}:${{ env.VERSION }}
${{ env.GHCR_REPO }}:${{ env.VERSION }}
${{ matrix.beanstalkd_version == 'v1.13' && matrix.alpine_version == '3.21' && format('{0}:latest,{1}:latest', env.DOCKERHUB_REPO, env.GHCR_REPO) || '' }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Export digest
- name: Check image
if: env.IS_RELEASE == 'true'
run: |
mkdir -p /tmp/digests/${{ env.VERSION }}
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${{ env.VERSION }}/${digest#sha256:}"

- name: Upload digest
if: env.IS_RELEASE == 'true'
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.VERSION }}-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/${{ env.VERSION }}/*
if-no-files-found: error
retention-days: 1

release:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request')
needs: [build]
strategy:
fail-fast: false
matrix:
alpine_version: ["3.18", "3.19", "3.20", "3.21"]
beanstalkd_version: ["v1.8", "v1.9", "v1.10", "v1.11", "v1.12", "v1.13"]
steps:
- name: Prepare
run: |
echo "VERSION=${{ matrix.beanstalkd_version }}-alpine-${{ matrix.alpine_version }}" >> $GITHUB_ENV

- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests/${{ env.VERSION }}
pattern: digests-${{ env.VERSION }}-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests/${{ env.VERSION }}
run: |
# Create manifest for latest tag if this is the latest version
if [[ "${{ matrix.beanstalkd_version }}" == "v1.13" && "${{ matrix.alpine_version }}" == "3.21" ]]; then
docker buildx imagetools create -t ${{ env.DOCKER_REPOSITORY }}:latest \
-t ${{ env.GHCR_REPOSITORY }}:latest \
$(printf '${{ env.DOCKER_REPOSITORY }}@sha256:%s ' *)
fi

docker buildx imagetools create -t ${{ env.DOCKER_REPOSITORY }}:${{ env.VERSION }} \
-t ${{ env.GHCR_REPOSITORY }}:${{ env.VERSION }} \
$(printf '${{ env.DOCKER_REPOSITORY }}@sha256:%s ' *) \
$(printf '${{ env.GHCR_REPOSITORY }}@sha256:%s ' *)

- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.DOCKER_REPOSITORY }}:${{ env.VERSION }}
docker buildx imagetools inspect ${{ env.GHCR_REPOSITORY }}:${{ env.VERSION }}
if [[ "${{ matrix.beanstalkd_version }}" == "v1.13" && "${{ matrix.alpine_version }}" == "3.21" ]]; then
docker buildx imagetools inspect ${{ env.DOCKER_REPOSITORY }}:latest
docker buildx imagetools inspect ${{ env.GHCR_REPOSITORY }}:latest
fi
docker buildx imagetools inspect ${{ env.DOCKERHUB_REPO }}:${{ env.VERSION }}
docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ env.VERSION }}
Loading