Skip to content

push to docker.io and ghcr.io #3

push to docker.io and ghcr.io

push to docker.io and ghcr.io #3

name: Create and publish a Docker image
on:
push:
branches: ['main']
env:
REGISTRY: ghcr.io
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write
strategy:
fail-fast: false
matrix:
include:
- version: 3.6.4
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set meta
id: meta
uses: docker/metadata-action@v5
with:
tags: ${{ matrix.version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to the GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
build-args: KUBEASZ_VER=${{ matrix.version }}
context: .
tags: |
easzlab/kubeasz:${{ steps.meta.outputs.tags }}
ghcr.io/easzlab/kubeasz:${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
push: true