Skip to content

Commit def4bed

Browse files
fix(ci): fix publish-containers workflow — matrix not available in job-level if
Move component filter from job-level 'if' (where matrix context is unavailable) to a step-level check. All subsequent steps are gated on steps.check.outputs.skip. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1b72b21 commit def4bed

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

.github/workflows/publish-containers.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,25 @@ jobs:
6161
context: .
6262
port: 8081
6363

64-
# Build all on release, or filter by selected component on dispatch
65-
if: >-
66-
github.event_name == 'release' ||
67-
github.event.inputs.component == 'all' ||
68-
github.event.inputs.component == matrix.component
69-
7064
steps:
65+
- name: Check if this component should build
66+
id: check
67+
run: |
68+
EVENT="${{ github.event_name }}"
69+
SELECTED="${{ github.event.inputs.component }}"
70+
CURRENT="${{ matrix.component }}"
71+
if [ "$EVENT" = "release" ] || [ "$SELECTED" = "all" ] || [ "$SELECTED" = "$CURRENT" ]; then
72+
echo "skip=false" >> "$GITHUB_OUTPUT"
73+
else
74+
echo "skip=true" >> "$GITHUB_OUTPUT"
75+
echo "Skipping $CURRENT (selected: $SELECTED)"
76+
fi
77+
7178
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
79+
if: steps.check.outputs.skip != 'true'
7280

7381
- name: Set image tag
82+
if: steps.check.outputs.skip != 'true'
7483
id: tag
7584
run: |
7685
if [ "${{ github.event_name }}" = "release" ]; then
@@ -83,16 +92,19 @@ jobs:
8392
echo "Image tag: $TAG"
8493
8594
- name: Set up Docker Buildx
95+
if: steps.check.outputs.skip != 'true'
8696
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
8797

8898
- name: Log in to GHCR
99+
if: steps.check.outputs.skip != 'true'
89100
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
90101
with:
91102
registry: ${{ env.REGISTRY }}
92103
username: ${{ github.actor }}
93104
password: ${{ secrets.GITHUB_TOKEN }}
94105

95106
- name: Extract metadata
107+
if: steps.check.outputs.skip != 'true'
96108
id: meta
97109
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
98110
with:
@@ -103,6 +115,7 @@ jobs:
103115
type=sha,prefix=
104116
105117
- name: Build and push
118+
if: steps.check.outputs.skip != 'true'
106119
id: build
107120
uses: docker/build-push-action@263435318d21b8e681c14492fe198e19c816612b # v6.18.0
108121
with:
@@ -118,6 +131,7 @@ jobs:
118131
cache-to: type=gha,mode=max
119132

120133
- name: Attest build provenance
134+
if: steps.check.outputs.skip != 'true'
121135
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
122136
with:
123137
subject-name: ${{ env.IMAGE_PREFIX }}/${{ matrix.component }}
@@ -126,6 +140,7 @@ jobs:
126140
continue-on-error: true
127141

128142
- name: Summary
143+
if: steps.check.outputs.skip != 'true'
129144
run: |
130145
echo "### ✅ Published \`${{ matrix.component }}\`" >> "$GITHUB_STEP_SUMMARY"
131146
echo "" >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)