Publish Docker image #1
Workflow file for this run
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 image | |
on: | |
release: | |
types: [published] | |
env: | |
DOCKER_REGISTRY: segence | |
DOCKER_IMAGE_NAME: ${{ github.event.repository.name }} | |
jobs: | |
push_to_registry: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
classifier: [mysql] | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- 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.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} | |
- name: Set Versions | |
uses: actions/github-script@v7 | |
id: set_version | |
with: | |
script: | | |
const tag = context.ref.substring(10) | |
const tag_semver_docker_compatible = tag.replace('v', '').replace('+', '-') | |
core.setOutput('tag_semver_docker_compatible', tag_semver_docker_compatible) | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./${{ matrix.classifier }} | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{steps.set_version.outputs.tag_semver_docker_compatible}}-${{ matrix.classifier }} | |
labels: ${{ steps.meta.outputs.labels }} |