Skip to content

Commit 676b287

Browse files
committed
Add DRY_RUN for PR-based runs
1 parent f2629fc commit 676b287

5 files changed

Lines changed: 14 additions & 6 deletions

File tree

.github/workflows/fedora-centos.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ permissions:
1414
packages: write
1515

1616
env:
17+
DRY_RUN: ${{ github.event_name == 'pull_request' && '1' || '' }}
1718
CACHE_URL: ghcr.io/${{ github.repository }}/cache
1819

1920
jobs:

.github/workflows/rhel.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ permissions:
1212
packages: write
1313

1414
env:
15+
DRY_RUN: ${{ github.event_name == 'pull_request' && '1' || '' }}
1516
FOUNDRY_IMAGE: ghcr.io/${{ github.repository }}/foundry:${{ github.ref == 'refs/heads/main' && 'latest' || github.sha }}
1617
FOUNDRY_IMAGE_HEAD: ghcr.io/${{ github.repository }}/foundry:latest
1718
# private cache registry
@@ -49,6 +50,7 @@ jobs:
4950
-f Containerfile.foundry \
5051
-t "${{ env.FOUNDRY_IMAGE }}" .
5152
53+
# Always push foundry image so run-matrix can pull it; DRY_RUN only skips push inside the container (build-and-push.sh / generate-manifests.sh)
5254
- name: Push foundry image
5355
run: |
5456
podman push "${{ env.FOUNDRY_IMAGE }}"
@@ -111,5 +113,6 @@ jobs:
111113
-e "RHSM_USERNAME=$RHSM_USERNAME" -e "RHSM_PASSWORD=$RHSM_PASSWORD" \
112114
-e "CACHE_URL=$CACHE_URL" -e "CACHE_USERNAME=$CACHE_USERNAME" -e "CACHE_PASSWORD=$CACHE_PASSWORD" \
113115
-e "STORAGE_DRIVER=$STORAGE_DRIVER" -e "STORAGE_OPTS=$STORAGE_OPTS" -e "BUILDAH_ISOLATION=$BUILDAH_ISOLATION" \
116+
-e "DRY_RUN=$DRY_RUN" \
114117
"${{ env.FOUNDRY_IMAGE }}" \
115118
${{ matrix.script }} "$IMAGE"

.yamllint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
extends: default
33
rules:
44
line-length:
5-
max: 140
5+
max: 160
66
document-start: disable
77
truthy:
88
check-keys: false

build-and-push.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -euo pipefail
55
# REPO_USERNAME, REPO_PASSWORD - optional; quay.io login (if missing, skips all push)
66
# CACHE_URL, CACHE_USERNAME, CACHE_PASSWORD - optional; all three required for any cache use
77
# TO_IMAGE, TO_TAG, ARCH, CONTAINERFILE, FROM_IMAGE, FROM_TAG - build params
8+
# DRY_RUN - when set, skip all push operations (e.g. set for PR builds)
89

910
if [ -n "${REPO_USERNAME:-}" ] && [ -n "${REPO_PASSWORD:-}" ]; then
1011
echo "$REPO_PASSWORD" | buildah login -u "$REPO_USERNAME" --password-stdin quay.io
@@ -37,12 +38,14 @@ buildah build --layers --arch="$ARCH" \
3738
-f "Containerfile.${CONTAINERFILE}" \
3839
-t "$IMAGE" .
3940

40-
if [ -n "${REPO_USERNAME:-}" ] && [ -n "${REPO_PASSWORD:-}" ]; then
41+
if [ -z "${DRY_RUN:-}" ] && [ -n "${REPO_USERNAME:-}" ] && [ -n "${REPO_PASSWORD:-}" ]; then
4142
buildah push "$IMAGE"
4243
else
43-
echo "Push skipped: REPO_USERNAME or REPO_PASSWORD missing"
44+
echo "Push skipped: DRY_RUN is set or REPO_USERNAME or REPO_PASSWORD missing"
4445
fi
4546

46-
if [ -n "${USE_CACHE:-}" ]; then
47+
if [ -z "${DRY_RUN:-}" ] && [ -n "${USE_CACHE:-}" ]; then
4748
buildah push "$IMAGE" "$CACHE_IMAGE"
49+
elif [ -n "${DRY_RUN:-}" ] && [ -n "${USE_CACHE:-}" ]; then
50+
echo "Push skipped: DRY_RUN is set or REPO_USERNAME or REPO_PASSWORD missing"
4851
fi

generate-manifests.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -euo pipefail
55
# REPO_USERNAME, REPO_PASSWORD - quay.io login (optional; no push if missing)
66
# CACHE_URL, CACHE_USERNAME, CACHE_PASSWORD - optional; all three required for cache pull
77
# IMAGE, TAG, ARCHES - manifest params (ARCHES is space-separated)
8+
# DRY_RUN - when set, skip manifest push (e.g. set for PR builds)
89

910
if [ -n "${REPO_USERNAME:-}" ] && [ -n "${REPO_PASSWORD:-}" ]; then
1011
echo "$REPO_PASSWORD" | buildah login -u "$REPO_USERNAME" --password-stdin quay.io
@@ -43,8 +44,8 @@ for arch in $ARCHES; do
4344
done
4445

4546
echo "Pushing manifest to $IMAGE:$TAG"
46-
if [ -n "${REPO_USERNAME:-}" ] && [ -n "${REPO_PASSWORD:-}" ]; then
47+
if [ -z "${DRY_RUN:-}" ] && [ -n "${REPO_USERNAME:-}" ] && [ -n "${REPO_PASSWORD:-}" ]; then
4748
buildah manifest push --all "$IMAGE:$TAG" "docker://$IMAGE:$TAG"
4849
else
49-
echo "Push skipped: REPO_USERNAME or REPO_PASSWORD missing"
50+
echo "Push skipped: DRY_RUN is set or REPO_USERNAME or REPO_PASSWORD missing"
5051
fi

0 commit comments

Comments
 (0)