Skip to content

Commit 9c43cc8

Browse files
committed
ci(publish): add steps for building with(out) cache
1 parent e15abda commit 9c43cc8

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

.github/workflows/publish-2.7.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
- '2.7/**'
1111
schedule:
1212
- cron: '0 9 * * 2,6'
13-
- cron: '30 6 2 * *'
13+
- cron: '45 7 1 * *'
1414

1515
jobs:
1616
publish:
@@ -33,7 +33,7 @@ jobs:
3333
with:
3434
image: coatldev/python
3535
version: ${{ matrix.image.version }}
36-
build-cache: ${{ github.event.schedule == '0 7 1 * *' && 'false' || 'true' }}
36+
build-cache: ${{ github.event.schedule == '45 7 1 * *' && 'false' || 'true' }}
3737
variant: ${{ matrix.image.variant }}
3838
tags: ${{ matrix.image.tags }}
3939
username: ${{ vars.DOCKERHUB_USERNAME }}

.github/workflows/publish-3.12.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
- '3.12/**'
1111
schedule:
1212
- cron: '0 9 * * 1,5'
13-
- cron: '0 7 1 * *'
13+
- cron: '45 7 1 * *'
1414

1515
jobs:
1616
tagger:
@@ -60,7 +60,7 @@ jobs:
6060
with:
6161
image: coatldev/python
6262
version: ${{ matrix.image.version }}
63-
build-cache: ${{ github.event.schedule == '0 7 1 * *' && 'false' || 'true' }}
63+
build-cache: ${{ github.event.schedule == '45 7 1 * *' && 'false' || 'true' }}
6464
variant: ${{ matrix.image.variant }}
6565
tags: ${{ matrix.image.tags }}
6666
username: ${{ vars.DOCKERHUB_USERNAME }}

.github/workflows/publish-3.13.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
- '3.13/**'
1111
schedule:
1212
- cron: '0 9 * * 0,4'
13-
- cron: '0 7 1 * *'
13+
- cron: '45 7 1 * *'
1414

1515
jobs:
1616
tagger:
@@ -62,7 +62,7 @@ jobs:
6262
with:
6363
image: coatldev/python
6464
version: ${{ matrix.image.version }}
65-
build-cache: ${{ github.event.schedule == '0 7 1 * *' && 'false' || 'true' }}
65+
build-cache: ${{ github.event.schedule == '45 7 1 * *' && 'false' || 'true' }}
6666
variant: ${{ matrix.image.variant }}
6767
tags: ${{ matrix.image.tags }}
6868
username: ${{ vars.DOCKERHUB_USERNAME }}

.github/workflows/publish.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,41 @@ jobs:
7373
username: ${{ inputs.username }}
7474
password: ${{ secrets.password }}
7575

76-
- name: Build and push by digest
77-
id: build
76+
- name: Build and push by digest (cached)
77+
if: ${{ inputs.build-cache == 'true' }}
78+
id: build-cache
7879
uses: docker/build-push-action@v6
7980
with:
8081
cache-from: type=gha,scope=${{ inputs.version }}-${{ inputs.variant }}-${{ env.PLATFORM_PAIR }}
8182
cache-to: type=gha,scope=${{ inputs.version }}-${{ inputs.variant }}-${{ env.PLATFORM_PAIR }},mode=max
8283
file: ${{ inputs.version }}/${{ inputs.variant }}/Dockerfile
8384
labels: ${{ steps.meta.outputs.labels }}
84-
no-cache: ${{ ! inputs.build-cache }}
8585
outputs: type=image,name=${{ inputs.image }},push-by-digest=true,name-canonical=true,push=true
8686
platforms: ${{ matrix.builder.platform }}
8787

88-
- name: Export digest
88+
- name: Build and push by digest (no cache)
89+
if: ${{ inputs.build-cache != 'true' }}
90+
id: build-no-cache
91+
uses: docker/build-push-action@v6
92+
with:
93+
file: ${{ inputs.version }}/${{ inputs.variant }}/Dockerfile
94+
labels: ${{ steps.meta.outputs.labels }}
95+
no-cache: true
96+
outputs: type=image,name=${{ inputs.image }},push-by-digest=true,name-canonical=true,push=true
97+
platforms: ${{ matrix.builder.platform }}
98+
99+
- name: Export digest (cached)
100+
if: ${{ inputs.build-cache == 'true' }}
101+
run: |
102+
mkdir -p ${{ runner.temp }}/digests
103+
digest="${{ steps.build-cache.outputs.digest }}"
104+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
105+
106+
- name: Export digest (no cache)
107+
if: ${{ inputs.build-cache == 'false' }}
89108
run: |
90109
mkdir -p ${{ runner.temp }}/digests
91-
digest="${{ steps.build.outputs.digest }}"
110+
digest="${{ steps.build-no-cache.outputs.digest }}"
92111
touch "${{ runner.temp }}/digests/${digest#sha256:}"
93112
94113
- name: Upload digest

0 commit comments

Comments
 (0)