diff --git a/.github/workflows/version-check.yml b/.github/workflows/version-check.yml index ae59544f94ed..0405fd47f940 100644 --- a/.github/workflows/version-check.yml +++ b/.github/workflows/version-check.yml @@ -22,7 +22,7 @@ jobs: - name: Verify linked version matches core version id: version-check - run: ./script/ci/version_check.sh ${{ github.event.pull_request.body }} + run: ./script/ci/version_check.sh "${{ github.event.pull_request.body }}" - name: Add comment if versions differ if: steps.version-check.outputs.version_mismatch == 'true' diff --git a/script/ci/version_check.sh b/script/ci/version_check.sh index 39558a4984fd..29eaeb3ffe6e 100755 --- a/script/ci/version_check.sh +++ b/script/ci/version_check.sh @@ -31,10 +31,10 @@ set -e # script/ci/version_check -PR_BODY="$1" +PR_BODY="$@" # Extract URL from PR description -WP_URL=$(echo "${PR_BODY}" | grep -oE 'https://community.openproject.org/(wp|work_packages|projects/[^/]+/work_packages)/[0-9]+') +WP_URL=$(echo "$PR_BODY" | grep -oE 'https://community.openproject.org/(wp|work_packages|projects/[^/]+/work_packages)/[0-9]+' || true) if [ -z "$WP_URL" ]; then echo "::warning::PR description does not contain a valid URL to an OpenProject ticket." @@ -56,7 +56,7 @@ if [ "$HTTP_STATUS" -ne 200 ]; then exit 0 fi -VERSION_FROM_API=$(jq -r '._links.version.title // empty' response.json) +VERSION_FROM_API=$(jq -r '._links.version.title // "not set"' response.json) if [ -z "$VERSION_FROM_API" ]; then echo "::warning::Failed to extract version from API response." exit 0 @@ -73,11 +73,10 @@ echo "Version from file: $VERSION_FROM_FILE" if [[ "$VERSION_FROM_API" != "$VERSION_FROM_FILE" ]]; then echo "Version mismatch detected." - - echo "version_mismatch=true" >> $GITHUB_OUTPUT - echo "wp_url=${WP_URL}" >> $GITHUB_OUTPUT - echo "wp_version=${VERSION_FROM_API}" >> $GITHUB_OUTPUT - echo "core_version=${VERSION_FROM_FILE}" >> $GITHUB_OUTPUT + echo "version_mismatch=true" >> "$GITHUB_OUTPUT" + echo "wp_url=${WP_URL}" >> "$GITHUB_OUTPUT" + echo "wp_version=${VERSION_FROM_API}" >> "$GITHUB_OUTPUT" + echo "core_version=${VERSION_FROM_FILE}" >> "$GITHUB_OUTPUT" else echo "Version from the work package ${WORK_PACKAGE_ID} matches the version in the version file this PR targets." fi