Skip to content

Update docker-image.yml [SKIP CI] #44

Update docker-image.yml [SKIP CI]

Update docker-image.yml [SKIP CI] #44

Workflow file for this run

name: Publish Docker image
on:
push:
branches:
- main
- release/*
tags:
- 'v*'
jobs:
push_to_registry:
name: Push Docker image to Docker Hub & GHCR
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check Out Repo
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
# Store the version, stripping any v-prefix
- name: Write release version
id: get_release_version
if: ${{ github.ref_type == 'tag' }}
run: |
TAG_VERSION=${GITHUB_REF_NAME#v}
echo version-without-v: $TAG_VERSION
echo "version-without-v=$TAG_VERSION" >> $GITHUB_OUTPUT
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Login to the Github Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to My Gitea Container registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.GITEA_SERVER }}
username: ${{ secrets.GITEA_USERNAME }}
password: ${{ secrets.GITEA_ACCESS_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
docker.io/${{ github.repository }}
ghcr.io/${{ github.repository }}
${{ secrets.GITEA_SERVER }}/${{ secrets.GITEA_REPOSITORY }}
flavor: |
latest=auto
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest
- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
KUSTOMIZE_IMAGE=${{ 'docker.io/line/kubectl-kustomize' }}:${{ steps.get_release_version.outputs.version-without-v || 'latest' }}
- name: Image digest
run: |
echo "Image digest: ${{ steps.docker_build.outputs.digest }}"