Skip to content

Commit c9b33a2

Browse files
chore(github): fix docker
1 parent 12a89ec commit c9b33a2

3 files changed

Lines changed: 75 additions & 109 deletions

File tree

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
_commit: v0.15.24-1-g7bf60db
1+
_commit: v0.15.24-2-gbd31d85
22
_src_path: .
33
attestations_enabled: true
44
author_email: helmuthva@gmail.com

.github/workflows/_docker-publish.yml

Lines changed: 35 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -33,66 +33,49 @@ jobs:
3333
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
3434

3535

36-
- name: Log in to Docker Hub
37-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
36+
- name: "(all target): Build and push Docker image"
37+
id: build-and-push-all
38+
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
3839
with:
39-
username: ${{ secrets.DOCKER_IO_USERNAME }}
40-
password: ${{ secrets.DOCKER_IO_PASSWORD }}
40+
context: .
41+
file: ./Dockerfile
42+
target: all
43+
platforms: linux/amd64,linux/arm64
44+
push: true
45+
tags: ${{ steps.meta-all.outputs.tags }}
46+
labels: ${{ steps.meta-all.outputs.labels }}
4147

4248

43-
- name: Log in to GitHub Container Registry
44-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
45-
with:
46-
registry: ghcr.io
47-
username: ${{ github.repository_owner }}
48-
password: ${{ secrets.GITHUB_TOKEN }}
4949

50-
- name: Extract metadata for Docker
51-
id: meta
52-
uses: docker/metadata-action@38b8a86137171c128513e9be0b97bc476fbffcb5 # v5.6.0
53-
with:
54-
images: |
55-
ghcr.io/helmut-hoffer-von-ankershoffen/oe-python-template
56-
57-
${{ env.DOCKER_IO_IMAGE_NAME_ALL }}
58-
59-
flavor: |
60-
latest=auto
61-
prefix=
62-
suffix=
63-
tags: |
64-
type=semver,pattern=v
65-
type=semver,pattern=v.
66-
type=semver,pattern=v
67-
68-
- name: Build and push Docker image (all)
69-
uses: docker/build-push-action@e6ef1f314e8a75f35e85dbd71ebe08d4b3005fc8 # v6.2.0
50+
- name: "(slim target): Build and push Docker image"
51+
id: build-and-push-slim
52+
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
7053
with:
7154
context: .
72-
push: true
73-
tags: ${{ steps.meta.outputs.tags }}
74-
labels: ${{ steps.meta.outputs.labels }}
55+
file: ./Dockerfile
56+
target: slim
7557
platforms: linux/amd64,linux/arm64
76-
target: all
77-
provenance: true
78-
cache-from: type=gha
79-
cache-to: type=gha,mode=max
58+
push: true
59+
tags: ${{ steps.meta-slim.outputs.tags }}
60+
labels: ${{ steps.meta-slim.outputs.labels }}
61+
8062

81-
- name: Build and push Docker image (slim)
82-
uses: docker/build-push-action@e6ef1f314e8a75f35e85dbd71ebe08d4b3005fc8 # v6.2.0
63+
64+
65+
66+
- name: "(all target): Generate artifact attestation"
67+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
8368
with:
84-
context: .
85-
push: true
86-
tags: |
87-
ghcr.io/helmut-hoffer-von-ankershoffen/oe-python-template-slim:latest
88-
ghcr.io/helmut-hoffer-von-ankershoffen/oe-python-template-slim:${{ github.ref_name }}
69+
subject-name: ${{ env.DOCKER_IO_REGISTRY }}/${{ env.DOCKER_IO_IMAGE_NAME_ALL }}
70+
subject-digest: ${{ steps.build-and-push-all.outputs.digest }}
71+
push-to-registry: true
8972

90-
${{ env.DOCKER_IO_IMAGE_NAME_SLIM }}:latest
91-
${{ env.DOCKER_IO_IMAGE_NAME_SLIM }}:${{ github.ref_name }}
9273

93-
labels: ${{ steps.meta.outputs.labels }}
94-
platforms: linux/amd64,linux/arm64
95-
target: slim
96-
provenance: true
97-
cache-from: type=gha
98-
cache-to: type=gha,mode=max
74+
75+
76+
- name: "(slim target): Generate artifact attestation"
77+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
78+
with:
79+
subject-name: ${{ env.DOCKER_IO_REGISTRY }}/${{ env.DOCKER_IO_IMAGE_NAME_SLIM }}
80+
subject-digest: ${{ steps.build-and-push-slim.outputs.digest }}
81+
push-to-registry: true

template/.github/workflows/_docker-publish.yml.jinja

Lines changed: 39 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -32,67 +32,50 @@ jobs:
3232
- name: Set up Docker Buildx
3333
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
3434

35-
{% if docker_io_enabled %}
36-
- name: Log in to Docker Hub
37-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
38-
with:
39-
username: {% raw %}${{ secrets.DOCKER_IO_USERNAME }}{% endraw %}
40-
password: {% raw %}${{ secrets.DOCKER_IO_PASSWORD }}{% endraw %}
41-
{% endif %}
42-
43-
- name: Log in to GitHub Container Registry
44-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
45-
with:
46-
registry: ghcr.io
47-
username: {% raw %}${{ github.repository_owner }}{% endraw %}
48-
password: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
49-
50-
- name: Extract metadata for Docker
51-
id: meta
52-
uses: docker/metadata-action@38b8a86137171c128513e9be0b97bc476fbffcb5 # v5.6.0
53-
with:
54-
images: |
55-
ghcr.io/{{ github_repository_owner }}/{{ github_repository_name }}
56-
{% if docker_io_enabled %}
57-
{% raw %}${{ env.DOCKER_IO_IMAGE_NAME_ALL }}{% endraw%}
58-
{% endif %}
59-
flavor: |
60-
latest=auto
61-
prefix=
62-
suffix=
63-
tags: |
64-
type=semver,pattern={{raw}}v{{version}}{{endraw}}
65-
type=semver,pattern={{raw}}v{{major}}.{{minor}}{{endraw}}
66-
type=semver,pattern={{raw}}v{{major}}{{endraw}}
67-
68-
- name: Build and push Docker image (all)
69-
uses: docker/build-push-action@e6ef1f314e8a75f35e85dbd71ebe08d4b3005fc8 # v6.2.0
35+
{% raw %}
36+
- name: "(all target): Build and push Docker image"
37+
id: build-and-push-all
38+
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
7039
with:
7140
context: .
72-
push: true
73-
tags: {% raw %}${{ steps.meta.outputs.tags }}{% endraw %}
74-
labels: {% raw %}${{ steps.meta.outputs.labels }}{% endraw %}
75-
platforms: linux/amd64,linux/arm64
41+
file: ./Dockerfile
7642
target: all
77-
provenance: true
78-
cache-from: type=gha
79-
cache-to: type=gha,mode=max
43+
platforms: linux/amd64,linux/arm64
44+
push: true
45+
tags: ${{ steps.meta-all.outputs.tags }}
46+
labels: ${{ steps.meta-all.outputs.labels }}
47+
{% endraw %}
8048

81-
- name: Build and push Docker image (slim)
82-
uses: docker/build-push-action@e6ef1f314e8a75f35e85dbd71ebe08d4b3005fc8 # v6.2.0
49+
{% raw %}
50+
- name: "(slim target): Build and push Docker image"
51+
id: build-and-push-slim
52+
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
8353
with:
8454
context: .
55+
file: ./Dockerfile
56+
target: slim
57+
platforms: linux/amd64,linux/arm64
8558
push: true
86-
tags: |
87-
ghcr.io/{{ github_repository_owner }}/{{ github_repository_name }}-slim:latest
88-
ghcr.io/{{ github_repository_owner }}/{{ github_repository_name }}-slim:{% raw %}${{ github.ref_name }}{% endraw %}
59+
tags: ${{ steps.meta-slim.outputs.tags }}
60+
labels: ${{ steps.meta-slim.outputs.labels }}
61+
{% endraw %}
62+
8963
{% if docker_io_enabled %}
90-
{% raw %}${{ env.DOCKER_IO_IMAGE_NAME_SLIM }}{% endraw %}:latest
91-
{% raw %}${{ env.DOCKER_IO_IMAGE_NAME_SLIM }}{% endraw %}:{% raw %}${{ github.ref_name }}{% endraw %}
92-
{% endif %}
93-
labels: {% raw %}${{ steps.meta.outputs.labels }}{% endraw %}
94-
platforms: linux/amd64,linux/arm64
95-
target: slim
96-
provenance: true
97-
cache-from: type=gha
98-
cache-to: type=gha,mode=max
64+
{% if attestations_enabled %}
65+
{% raw %}
66+
- name: "(all target): Generate artifact attestation"
67+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
68+
with:
69+
subject-name: ${{ env.DOCKER_IO_REGISTRY }}/${{ env.DOCKER_IO_IMAGE_NAME_ALL }}
70+
subject-digest: ${{ steps.build-and-push-all.outputs.digest }}
71+
push-to-registry: true{% endraw %}{% endif %}{% endif %}
72+
73+
{% if docker_io_enabled %}
74+
{% if attestations_enabled %}
75+
{% raw %}
76+
- name: "(slim target): Generate artifact attestation"
77+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
78+
with:
79+
subject-name: ${{ env.DOCKER_IO_REGISTRY }}/${{ env.DOCKER_IO_IMAGE_NAME_SLIM }}
80+
subject-digest: ${{ steps.build-and-push-slim.outputs.digest }}
81+
push-to-registry: true{% endraw %}{% endif %}{% endif %}

0 commit comments

Comments
 (0)