Skip to content

Commit 7fa1b59

Browse files
IONOS(CI): Add prerequisites validation to trigger-remote-dev-workflow
- Add build-artifact to needs array to ensure NC_VERSION output is available - Update if condition to verify both build-artifact and upload-to-artifactory succeeded - Add comprehensive validation step that checks all required variables before triggering remote workflow - Validates secrets (GITLAB_TOKEN, GITLAB_TRIGGER_URL) - Validates job outputs (NC_VERSION, ARTIFACTORY_LAST_BUILD_PATH) - Validates GitHub context variables (sha, run_id, ref_name) - Abort with error if any required variable is missing This prevents the remote workflow from being triggered with missing critical variables like NC_VERSION, which was previously not available because build-artifact was not in the needs array. Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
1 parent 8405719 commit 7fa1b59

1 file changed

Lines changed: 62 additions & 1 deletion

File tree

.github/workflows/build-artifact.yml

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,17 +919,78 @@ jobs:
919919
runs-on: self-hosted
920920

921921
name: Trigger remote workflow
922-
needs: [upload-to-artifactory]
922+
needs: [build-artifact, upload-to-artifactory]
923923
# Trigger remote build on "ionos-dev|ionos-stable|rc/*" branch *push* defined in the on:push:branches
924924
# Can be disabled via repository variable 'DISABLE_REMOTE_TRIGGER' (set to 'true' to disable)
925925
# Configure at: https://github.com/IONOS-Productivity/ncw-server/settings/variables/actions
926926
if: |
927927
always() &&
928928
github.event_name == 'push' &&
929929
(github.ref_name == 'ionos-dev' || github.ref_name == 'ionos-stable' || startsWith(github.ref_name, 'rc/')) &&
930+
needs.build-artifact.result == 'success' &&
930931
needs.upload-to-artifactory.result == 'success' &&
931932
vars.DISABLE_REMOTE_TRIGGER != 'true'
932933
steps:
934+
- name: Check prerequisites
935+
run: |
936+
echo "Checking if all required variables are set..."
937+
error_count=0
938+
939+
# Check secrets
940+
if [ -z "${{ secrets.GITLAB_TOKEN }}" ]; then
941+
echo "::error::GITLAB_TOKEN secret is not set"
942+
error_count=$((error_count + 1))
943+
fi
944+
945+
if [ -z "${{ secrets.GITLAB_TRIGGER_URL }}" ]; then
946+
echo "::error::GITLAB_TRIGGER_URL secret is not set"
947+
error_count=$((error_count + 1))
948+
fi
949+
950+
# Check required outputs from previous jobs
951+
if [ -z "${{ needs.build-artifact.outputs.NC_VERSION }}" ]; then
952+
echo "::error::NC_VERSION output from build-artifact job is not set"
953+
error_count=$((error_count + 1))
954+
else
955+
echo "✓ NC_VERSION: ${{ needs.build-artifact.outputs.NC_VERSION }}"
956+
fi
957+
958+
if [ -z "${{ needs.upload-to-artifactory.outputs.ARTIFACTORY_LAST_BUILD_PATH }}" ]; then
959+
echo "::error::ARTIFACTORY_LAST_BUILD_PATH output from upload-to-artifactory job is not set"
960+
error_count=$((error_count + 1))
961+
else
962+
echo "✓ ARTIFACTORY_LAST_BUILD_PATH: ${{ needs.upload-to-artifactory.outputs.ARTIFACTORY_LAST_BUILD_PATH }}"
963+
fi
964+
965+
# Check GitHub context variables
966+
if [ -z "${{ github.sha }}" ]; then
967+
echo "::error::github.sha is not set"
968+
error_count=$((error_count + 1))
969+
else
970+
echo "✓ GITHUB_SHA: ${{ github.sha }}"
971+
fi
972+
973+
if [ -z "${{ github.run_id }}" ]; then
974+
echo "::error::github.run_id is not set"
975+
error_count=$((error_count + 1))
976+
else
977+
echo "✓ BUILD_ID: ${{ github.run_id }}"
978+
fi
979+
980+
if [ -z "${{ github.ref_name }}" ]; then
981+
echo "::error::github.ref_name is not set"
982+
error_count=$((error_count + 1))
983+
else
984+
echo "✓ BRANCH: ${{ github.ref_name }}"
985+
fi
986+
987+
# Abort if any required variable is not set
988+
if [ $error_count -ne 0 ]; then
989+
echo "::error::Required variables are not set. Aborting."
990+
exit 1
991+
fi
992+
993+
echo "✅ All required variables are set"
933994
- name: Trigger remote workflow
934995
run: |
935996
# Enable command echo for debugging purposes

0 commit comments

Comments
 (0)