Skip to content

Commit b30e8e8

Browse files
authored
Do not always push images (#56)
This stops unconditional push of container images e.g. in `pull_request` events.
1 parent e2ca0cf commit b30e8e8

File tree

5 files changed

+30
-25
lines changed

5 files changed

+30
-25
lines changed

.github/workflows/debian.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ defaults:
1717
shell: bash
1818

1919
env:
20+
PUSH: ${{ github.event == 'push' && github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
2021
CONTAINER_REGISTRY: ghcr.io
2122
BUILDKIT_PROGRESS: plain
2223
CONAN_VERSION: 2.19.1
@@ -137,21 +138,21 @@ jobs:
137138
BASE_IMAGE=${{ env.CONTAINER_IMAGE_GCC && format('{0}:{1}-{2}', env.CONTAINER_IMAGE_GCC, matrix.os.compiler_version, matrix.os.release) || format('gcc:{0}-{1}', matrix.os.compiler_version, matrix.os.release) }}
138139
context: .
139140
file: docker/debian/Dockerfile
140-
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=true
141+
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ env.PUSH }}
141142
platforms: ${{ matrix.architecture.platform }}
142143
provenance: mode=max
143-
push: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
144+
push: ${{ env.PUSH }}
144145
sbom: true
145146
labels: ${{ steps.meta.outputs.labels }}
146147
target: ${{ matrix.os.compiler_name }}
147148
- name: Export digest
148-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
149+
if: ${{ env.PUSH }}
149150
run: |
150151
mkdir -p /tmp/digests
151152
DIGEST="${{ steps.build.outputs.digest }}"
152153
touch "/tmp/digests/${DIGEST#sha256:}"
153154
- name: Upload digest
154-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
155+
if: ${{ env.PUSH }}
155156
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
156157
with:
157158
name: digests-${{ matrix.os.release }}-${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-${{ env.PLATFORM_PAIR }}
@@ -160,7 +161,7 @@ jobs:
160161
retention-days: 1
161162

162163
merge:
163-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
164+
if: ${{ github.event == 'push' && github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
164165
strategy:
165166
matrix:
166167
os:

.github/workflows/gcc.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ defaults:
1616
shell: bash
1717

1818
env:
19+
PUSH: ${{ github.event == 'push' && github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
1920
CONTAINER_REGISTRY: ghcr.io
2021
BUILDKIT_PROGRESS: plain
2122

@@ -87,19 +88,19 @@ jobs:
8788
context: .
8889
file: docker/gcc/Dockerfile.${{ matrix.os.compiler_version }}-${{ matrix.os.release }}
8990
labels: ${{ steps.meta.outputs.labels }}
90-
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
91+
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ env.PUSH }}
9192
platforms: ${{ matrix.architecture.platform }}
9293
provenance: mode=max
93-
push: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
94+
push: ${{ env.PUSH }}
9495
sbom: true
9596
- name: Export digest
96-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
97+
if: ${{ env.PUSH }}
9798
run: |
9899
mkdir -p /tmp/digests
99100
DIGEST="${{ steps.build.outputs.digest }}"
100101
touch "/tmp/digests/${DIGEST#sha256:}"
101102
- name: Upload digest
102-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
103+
if: ${{ env.PUSH }}
103104
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
104105
with:
105106
name: digests-${{ matrix.os.compiler_version }}-${{ matrix.os.release }}-${{ env.PLATFORM_PAIR }}
@@ -108,7 +109,7 @@ jobs:
108109
retention-days: 1
109110

110111
merge:
111-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
112+
if: ${{ github.event == 'push' && github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
112113
strategy:
113114
matrix:
114115
os:

.github/workflows/rhel.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ defaults:
1717
shell: bash
1818

1919
env:
20+
PUSH: ${{ github.event == 'push' && github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
2021
CONTAINER_REGISTRY: ghcr.io
2122
REDHAT_REGISTRY: registry.redhat.io
2223
BUILDKIT_PROGRESS: plain
@@ -120,21 +121,21 @@ jobs:
120121
RHEL_VERSION=${{ matrix.os.release }}
121122
context: .
122123
file: docker/rhel/Dockerfile
123-
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=true
124+
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ env.PUSH }}
124125
platforms: ${{ matrix.architecture.platform }}
125126
provenance: mode=max
126-
push: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
127+
push: ${{ env.PUSH }}
127128
sbom: true
128129
labels: ${{ steps.meta.outputs.labels }}
129130
target: ${{ matrix.os.compiler_name }}
130131
- name: Export digest
131-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
132+
if: ${{ env.PUSH }}
132133
run: |
133134
mkdir -p /tmp/digests
134135
DIGEST="${{ steps.build.outputs.digest }}"
135136
touch "/tmp/digests/${DIGEST#sha256:}"
136137
- name: Upload digest
137-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
138+
if: ${{ env.PUSH }}
138139
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
139140
with:
140141
name: digests-${{ matrix.os.release }}-${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-${{ env.PLATFORM_PAIR }}
@@ -143,7 +144,7 @@ jobs:
143144
retention-days: 1
144145

145146
merge:
146-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
147+
if: ${{ github.event == 'push' && github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
147148
strategy:
148149
matrix:
149150
os:

.github/workflows/tools-rippled.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ defaults:
1616
shell: bash
1717

1818
env:
19+
PUSH: ${{ github.event == 'push' && github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
1920
CONTAINER_REGISTRY: ghcr.io
2021
BUILDKIT_PROGRESS: plain
2122
CMAKE_VERSION: 3.31.6
@@ -91,21 +92,21 @@ jobs:
9192
GRAPHVIZ_VERSION=${{ env.GRAPHVIZ_VERSION }}
9293
PRE_COMMIT_VERSION=${{ env.PRE_COMMIT_VERSION }}
9394
context: docker/tools-rippled
94-
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=true
95+
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ env.PUSH }}
9596
platforms: ${{ matrix.architecture.platform }}
9697
provenance: mode=max
97-
push: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
98+
push: ${{ env.PUSH }}
9899
sbom: true
99100
labels: ${{ steps.meta.outputs.labels }}
100101
target: ${{ matrix.tool }}
101102
- name: Export digest
102-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
103+
if: ${{ env.PUSH }}
103104
run: |
104105
mkdir -p /tmp/digests
105106
DIGEST="${{ steps.build.outputs.digest }}"
106107
touch "/tmp/digests/${DIGEST#sha256:}"
107108
- name: Upload digest
108-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
109+
if: ${{ env.PUSH }}
109110
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
110111
with:
111112
name: digests-${{ matrix.tool }}-${{ env.PLATFORM_PAIR }}
@@ -114,7 +115,7 @@ jobs:
114115
retention-days: 1
115116

116117
merge:
117-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
118+
if: ${{ github.event == 'push' && github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
118119
strategy:
119120
matrix:
120121
tool:

.github/workflows/ubuntu.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ defaults:
1717
shell: bash
1818

1919
env:
20+
PUSH: ${{ github.event == 'push' && github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
2021
CONTAINER_REGISTRY: ghcr.io
2122
BUILDKIT_PROGRESS: plain
2223
CONAN_VERSION: 2.19.1
@@ -116,21 +117,21 @@ jobs:
116117
UBUNTU_VERSION=${{ matrix.os.release }}
117118
context: .
118119
file: docker/ubuntu/Dockerfile
119-
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=true
120+
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ env.PUSH }}
120121
platforms: ${{ matrix.architecture.platform }}
121122
provenance: mode=max
122-
push: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
123+
push: ${{ env.PUSH }}
123124
sbom: true
124125
labels: ${{ steps.meta.outputs.labels }}
125126
target: ${{ matrix.os.compiler_name }}
126127
- name: Export digest
127-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
128+
if: ${{ env.PUSH }}
128129
run: |
129130
mkdir -p /tmp/digests
130131
DIGEST="${{ steps.build.outputs.digest }}"
131132
touch "/tmp/digests/${DIGEST#sha256:}"
132133
- name: Upload digest
133-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
134+
if: ${{ env.PUSH }}
134135
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
135136
with:
136137
name: digests-${{ matrix.os.release }}-${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-${{ env.PLATFORM_PAIR }}
@@ -139,7 +140,7 @@ jobs:
139140
retention-days: 1
140141

141142
merge:
142-
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
143+
if: ${{ github.event == 'push' && github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
143144
strategy:
144145
matrix:
145146
os:

0 commit comments

Comments
 (0)