Skip to content

Update docker-publish.yml #44

Update docker-publish.yml

Update docker-publish.yml #44

Workflow file for this run

# This can be named anything, it'll show up in the GitHub Actions UI.
name: "Docker publish"
# This workflow will only run when git tags are pushed that start with `v*`,
# meaning `v123` or `v1.0.0` will work but `0.1.0` won't, if you don't want to
# prefix tags with `v` then remove the `v`.
on:
push:
tags:
# - "v*"
- "*"
jobs:
# This can also be named anything, it'll show up in the GitHub Actions UI.
build-and-push-image:
# Let's use the latest Ubuntu version for our CI environment.
runs-on: "ubuntu-latest"
# Most of the steps are things we covered in the Buildx basics post.
# They are just wrapped up into GitHub Actions instead of being raw shell
# commands we run manually.
steps:
# Literally git checkout the code, this is standard in most actions.
- name: "Checkout"
uses: "actions/checkout@v4"
# Allow the CI environment to emulate multiple CPU architectures.
- name: "Set up QEMU"
uses: "docker/setup-qemu-action@v3"
# Create and configure the Buildx context.
- name: "Set up Docker Buildx"
uses: "docker/setup-buildx-action@v3"
# Log into the Docker Hub (more on this in a bit).
- name: "Login to Docker Hub"
uses: "docker/login-action@v3"
with:
username: "${{ secrets.DOCKER_HUB_USER }}"
password: "${{ secrets.DOCKER_HUB_PASSWORD }}"
- name: "Login to Github Container Registry"
uses: "docker/login-action@v3"
with:
registry: "ghcr.io"
username: "${{ github.actor }}"
password: "${{ secrets.GHCR_PAT }}"
# Push images for X platforms to the Docker Hub (more on this in a bit).
- name: "Build and push image tags"
uses: "docker/build-push-action@v6"
with:
context: "."
platforms: "linux/amd64,linux/arm64"
push: true
tags: |
"${{ github.repository }}:latest"
"${{ github.repository }}:${{ github.ref_name }}"
"ghcr.io/user/${{ github.repository }}:latest"
"ghcr.io/user/${{ github.repository }}:${{ github.ref_name }}"