generated from KemingHe/agentic-template
-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (72 loc) · 3.31 KB
/
docker-publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Publish Image
on:
release:
types:
- published
# Defines custom environment variables for the workflow
env:
REGISTRY: ghcr.io
# Docker requires lowercase names for both images and cache references
IMAGE_NAME: keminghe/strain-seer
REPO_NAME: keminghe/strain-seer
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
build-and-push-image:
if: github.repository == 'KemingHe/strain-seer' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Log in to the Container registry
# Pinned 3rd party action to commit hash of release v3.4.0 on 03/14/2025 to prevent supply chain attacks
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
# Pinned 3rd party action to commit hash of release v5.7.0 on 02/26/2025 to prevent supply chain attacks
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
# Add support for more platforms, i.e. linux/arm64 (macOS M1/M2) with QEMU
- name: Set up QEMU
# Pinned 3rd party action to commit hash of release v3.6.0 on 02/28/2025 to prevent supply chain attacks
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392
# Enable advanced build features like cache export
- name: Set up Docker Buildx
# Pinned 3rd party action to commit hash of release v3.10.0 on 02/26/2025 to prevent supply chain attacks
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2
- name: Build and push Docker image
id: push
# Pinned 3rd party action to commit hash of release v6.15.0 on 02/26/2025 to prevent supply chain attacks
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64/v8
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_NAME }}:buildcache
cache-to: type=gha,mode=max,type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_NAME }}:buildcache
build-args: BUILD_DATE=${{ github.event.release.created_at }},VCS_REF=${{ github.sha }}
outputs: type=image,imageid=imageid,digest=digest,metadata=metadata
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true