Skip to content

docker

docker #1

name: docker
on:
push:
tags:
- "v*.*.*"
schedule:
- cron: "0 0 * * *"
workflow_dispatch: {}
workflow_call:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
container:
runs-on: ubuntu-20.04
permissions:
id-token: write
packages: write
contents: read
timeout-minutes: 120
steps:
- name: Checkout repository
id: checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Install Docker BuildX
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
version: latest
driver-opts: image=moby/buildkit:master
buildkitd-flags: --debug
endpoint: unix:///var/run/docker.sock
- name: Create Builder
uses: docker/buildx-create-action@v1
with:
use: true
name: mybuilder
driver: docker-container
driver-opts: network=host
buildkitd-flags: --debug
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Finalize Docker Metadata
id: docker_tagging
run: |
# The same logic for tagging as in your original workflow...
# ... [Your previous logic here]
- name: Inspect Docker Metadata
run: |
echo "TAGS -> ${{ steps.docker_tagging.outputs.docker_tags }}"
echo "LABELS -> ${{ steps.meta.outputs.labels }}"
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.docker_tagging.outputs.docker_tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}