Skip to content

Merge branch 'release/v1.7.1' #52

Merge branch 'release/v1.7.1'

Merge branch 'release/v1.7.1' #52

Workflow file for this run

name: Build and Publish Docker Image
on:
push:
branches:
- main
tags:
- "v*.*.*"
pull_request:
branches:
- main
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
name: Build & Push Docker Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:latest
network=host
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
env:
DOCKER_METADATA_SHORT_SHA_LENGTH: 7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
# # disabled if major zero
# type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
type=sha,enable=true,priority=100,prefix=,suffix=,format=short
type=schedule,pattern={{date 'YYYYMMDD'}}
type=raw,value=latest,enable={{is_default_branch}}
labels: |
org.opencontainers.image.title=aigitcommit
org.opencontainers.image.description=AI-powered Git commit message generator
org.opencontainers.image.url=https://github.com/mingcheng/aigitcommit
org.opencontainers.image.vendor=${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
- name: Build and push Docker image
if: steps.meta.outputs.tags != ''
id: push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_DATE=${{ github.event.head_commit.timestamp }}
VCS_REF=${{ github.sha }}
VERSION=${{ steps.meta.outputs.version }}
# - name: Generate artifact attestation
# if: github.event_name != 'pull_request'
# uses: actions/attest-build-provenance@v3
# with:
# subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# subject-digest: ${{ steps.push.outputs.digest }}
# push-to-registry: false
# - name: Generate SBOM
# if: github.event_name != 'pull_request'
# uses: anchore/[email protected]
# with:
# image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.push.outputs.digest }}
# format: spdx-json
# output-file: sbom.spdx.json
# - name: Upload SBOM as artifact
# if: github.event_name != 'pull_request'
# uses: actions/upload-artifact@v4
# with:
# name: ${{ steps.short-sha.outputs.sha }}-sbom
# path: sbom.spdx.json
# retention-days: 90