Skip to content

Commit 7e77db7

Browse files
authored
fix: update and fix docker workflows (#794)
1 parent a6de121 commit 7e77db7

File tree

2 files changed

+58
-22
lines changed

2 files changed

+58
-22
lines changed

.github/workflows/docker-latest.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
name: Build and publish a Docker image for master branch
2+
3+
env:
4+
REGISTRY: ghcr.io
5+
IMAGE_NAME: ${{ github.repository }}
6+
27
on:
38
push:
49
branches:
@@ -13,18 +18,18 @@ jobs:
1318
- name: Set up QEMU
1419
uses: docker/setup-qemu-action@v2
1520
with:
16-
platforms: 'arm64,arm'
21+
platforms: 'arm64'
1722

1823
- name: Set up Docker Buildx
1924
id: buildx
2025
uses: docker/setup-buildx-action@v2
2126
with:
22-
platforms: linux/arm64,linux/amd64,linux/arm/v7
27+
platforms: linux/arm64,linux/amd64
2328

2429
- name: Login to GHCR
2530
uses: docker/login-action@v3
2631
with:
27-
registry: ghcr.io
32+
registry: ${{ env.REGISTRY }}
2833
username: ${{ github.repository_owner }}
2934
password: ${{ secrets.GITHUB_TOKEN }}
3035

@@ -35,4 +40,4 @@ jobs:
3540
platforms: ${{ steps.buildx.outputs.platforms }}
3641
push: true
3742
tags: |
38-
ghcr.io/${{ github.repository }}:latest
43+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

.github/workflows/release.yaml

+49-18
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ on:
33
branches:
44
- master
55

6-
permissions:
7-
contents: write
8-
pull-requests: write
9-
packages: write
10-
attestations: write
11-
id-token: write
6+
env:
7+
REGISTRY: ghcr.io
8+
IMAGE_NAME: ${{ github.repository }}
129

1310
name: release
1411
jobs:
1512
release_please:
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
id-token: write
17+
1618
runs-on: ubuntu-latest
1719
outputs:
1820
major: ${{ steps.release.outputs.major }}
@@ -44,39 +46,68 @@ jobs:
4446
if: ${{ steps.release.outputs.release_created }}
4547

4648
publish_docker:
49+
name: Create and publish a Docker image
4750
runs-on: ubuntu-latest
51+
52+
permissions:
53+
contents: read
54+
packages: write
55+
attestations: write
56+
id-token: write
57+
4858
needs: release_please
4959
if: ${{needs.release_please.outputs.release_created}}
60+
5061
steps:
5162
- run: echo version v${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}.${{needs.release_please.outputs.patch}}
5263

53-
- uses: actions/checkout@v4
64+
- name: Checkout repository
65+
uses: actions/checkout@v4
5466

5567
- name: Set up QEMU
5668
uses: docker/setup-qemu-action@v3
5769
with:
58-
platforms: 'arm64,arm'
70+
platforms: 'arm64'
5971

6072
- name: Set up Docker Buildx
6173
id: buildx
6274
uses: docker/setup-buildx-action@v3
6375
with:
64-
platforms: linux/arm64,linux/amd64,linux/arm/v7
76+
platforms: linux/arm64,linux/amd64
6577

66-
- name: Login to GHCR
78+
- name: Log in to the Container registry
6779
uses: docker/login-action@v3
6880
with:
69-
registry: ghcr.io
81+
registry: ${{ env.REGISTRY }}
7082
username: ${{ github.repository_owner }}
7183
password: ${{ secrets.GITHUB_TOKEN }}
7284

73-
- name: Build and push
74-
uses: docker/build-push-action@v5
85+
- name: Extract metadata (tags, labels) for Docker
86+
id: meta
87+
uses: docker/metadata-action@v5
88+
with:
89+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
90+
flavor: |
91+
latest=false
92+
tags: |
93+
type=semver,pattern={{version}},value=v${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}.${{needs.release_please.outputs.patch}}
94+
type=semver,pattern={{major}}.{{minor}},value=v${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}.${{needs.release_please.outputs.patch}}
95+
type=semver,pattern={{major}},value=v${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}.${{needs.release_please.outputs.patch}}
96+
97+
- name: Build and push Docker image
98+
id: push
99+
uses: docker/build-push-action@v6
75100
with:
76101
context: .
77-
platforms: ${{ steps.buildx.outputs.platforms }}
78102
push: true
79-
tags: |
80-
ghcr.io/${{ github.repository }}:${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}.${{needs.release_please.outputs.patch}}
81-
ghcr.io/${{ github.repository }}:${{needs.release_please.outputs.major}}.${{needs.release_please.outputs.minor}}
82-
ghcr.io/${{ github.repository }}:${{needs.release_please.outputs.major}}
103+
platforms: ${{ steps.buildx.outputs.platforms }}
104+
tags: ${{ steps.meta.outputs.tags }}
105+
labels: ${{ steps.meta.outputs.labels }}
106+
107+
- name: Generate artifact attestation
108+
uses: actions/attest-build-provenance@v1
109+
with:
110+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
111+
subject-digest: ${{ steps.push.outputs.digest }}
112+
push-to-registry: true
113+
github-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)