Publish Docker images to DockerHub #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Docker images to DockerHub | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
publish_images: | |
strategy: | |
fail-fast: false | |
matrix: | |
version: | |
[3.0.1] | |
include: | |
- version: 3.0.1 | |
other_tag: '3.0' | |
latest: true | |
# - version: 2.0.0 | |
# other_tag: '2.0' | |
# - version: 1.3.0 | |
# other_tag: '1.3' | |
# - version: 1.2.2 | |
# other_tag: '1.2' | |
# - version: 1.1.1 | |
# other_tag: '1.1' | |
# - version: 1.0.2 | |
# other_tag: '1.0' | |
name: Publish Docker image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- | |
# Add support for more platforms with QEMU (optional) | |
# https://github.com/docker/setup-qemu-action | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ secrets.IMAGE_NAME }} | |
tags: | | |
type=raw,value=${{ matrix.version }} | |
type=raw,value=${{ matrix.other_tag }},enable=${{ matrix.other_tag != null }} | |
type=raw,value=latest,enable=${{ matrix.latest != null }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ matrix.version }}/. | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
platforms: linux/amd64,linux/arm64 | |
publish_alpine_images: | |
strategy: | |
fail-fast: false | |
matrix: | |
version: | |
[3.0.1] | |
include: | |
- version: 3.0.1 | |
other_tag: '3.0' | |
latest: true | |
# - version: 2.0.0 | |
# other_tag: '2.0' | |
# - version: 1.3.0 | |
# other_tag: '1.3' | |
# - version: 1.2.2 | |
# other_tag: '1.2' | |
# - version: 1.1.1 | |
# other_tag: '1.1' | |
# - version: 1.0.2 | |
# other_tag: '1.0' | |
name: Publish Alpine Docker image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- | |
# Add support for more platforms with QEMU (optional) | |
# https://github.com/docker/setup-qemu-action | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Alpine docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ matrix.version }}/alpine/. | |
push: true | |
tags: ${{ secrets.IMAGE_NAME }}:${{ matrix.version }}-alpine | |
platforms: linux/amd64,linux/arm64 | |