Skip to content

Commit dc48008

Browse files
authored
chore: improve logic: don't imply failures if there are none; don't pass the build if there are failures (RHIDP-9067) (#90)
* chore: improve logic: don't imply failures if there are none; don't pass the build if there are failures (RHIDP-9067) Signed-off-by: Nick Boldt <nboldt@redhat.com> * tee to GITHUB_OUTPUT (which can fall back to a local temp file) so we get console output even if the script fails Signed-off-by: Nick Boldt <nboldt@redhat.com> * for now always pass the export-dynamic.sh step, so we can get all the followup logging steps to still run even if the export fails Signed-off-by: Nick Boldt <nboldt@redhat.com> --------- Signed-off-by: Nick Boldt <nboldt@redhat.com>
1 parent 45ff7cb commit dc48008

2 files changed

Lines changed: 23 additions & 16 deletions

File tree

.github/workflows/export-dynamic.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ jobs:
286286
image-repository-prefix: ${{ steps.set-image-tag-name.outputs.IMAGE_REPOSITORY_PREFIX }}
287287
image-tag-prefix: ${{ inputs.image-tag-prefix }}
288288
last-publish-commit: ${{ inputs.last-publish-commit }}
289+
run:
290+
# for now always pass this step so we can get all the followup logging steps to still run even if the export fails
291+
${{ github.action_path }}/export-dynamic.sh || true
289292

290293
- name: Set artifacts name suffix
291294
id: set-artifacts-name-suffix

export-dynamic/export-dynamic.sh

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ else
159159
set -e
160160
popd > /dev/null
161161
done < "${INPUTS_PLUGINS_FILE}"
162-
echo "Plugins with failed exports: ${errors[*]}"
162+
if [[ ${#errors[@]} -gt 0 ]]; then
163+
echo "Plugins with failed exports: ${errors[*]}"
164+
fi
163165
fi
164166

165167
FAILED_EXPORTS_OUTPUT=${FAILED_EXPORTS_OUTPUT:-"failed-exports-output"}
@@ -176,21 +178,23 @@ do
176178
echo "$image" >> "$PUBLISHED_EXPORTS_OUTPUT"
177179
done
178180

179-
# shellcheck disable=SC2129 disable=SC2086
180-
if [[ "$GITHUB_OUTPUT" != "" ]]
181-
then
182-
echo "FAILED_EXPORTS<<EOF" >> $GITHUB_OUTPUT
183-
cat $FAILED_EXPORTS_OUTPUT >> $GITHUB_OUTPUT
184-
echo "EOF" >> $GITHUB_OUTPUT
181+
# write to a temp file if the GITHUB_OUTPUT pipe isn't set
182+
if [[ ! $GITHUB_OUTPUT ]]; then GITHUB_OUTPUT=/tmp/github_output.txt; fi
185183

186-
echo "PUBLISHED_EXPORTS<<EOF" >> $GITHUB_OUTPUT
187-
cat $PUBLISHED_EXPORTS_OUTPUT >> $GITHUB_OUTPUT
188-
echo "EOF" >> $GITHUB_OUTPUT
184+
echo "FAILED_EXPORTS<<EOF" | tee -a "$GITHUB_OUTPUT"
185+
cat "$FAILED_EXPORTS_OUTPUT" | tee -a "$GITHUB_OUTPUT"
186+
echo "EOF" | tee -a "$GITHUB_OUTPUT"
189187

190-
if [[ "${skipWorkspace}" == "true" ]]
191-
then
192-
echo "WORKSPACE_SKIPPED_UNCHANGED_SINCE=${INPUTS_LAST_PUBLISH_COMMIT}" >> $GITHUB_OUTPUT
193-
else
194-
echo "WORKSPACE_SKIPPED_UNCHANGED_SINCE=false" >> $GITHUB_OUTPUT
195-
fi
188+
echo "PUBLISHED_EXPORTS<<EOF" | tee -a "$GITHUB_OUTPUT"
189+
cat "$PUBLISHED_EXPORTS_OUTPUT" | tee -a "$GITHUB_OUTPUT"
190+
echo "EOF" | tee -a "$GITHUB_OUTPUT"
191+
192+
if [[ "${skipWorkspace}" == "true" ]]
193+
then
194+
echo "WORKSPACE_SKIPPED_UNCHANGED_SINCE=${INPUTS_LAST_PUBLISH_COMMIT}" | tee -a "$GITHUB_OUTPUT"
195+
else
196+
echo "WORKSPACE_SKIPPED_UNCHANGED_SINCE=false" | tee -a "$GITHUB_OUTPUT"
196197
fi
198+
199+
# exit a return code equivalent to the number of errors
200+
exit $((${#errors[@]}))

0 commit comments

Comments
 (0)