Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

fix event name check, make output less bloated

Markus Kahl4b710176acdc
diff --git a/.github/workflows/downstream-ci.yml b/.github/workflows/downstream-ci.yml
index d1c52e799e0..ef16793c02b 100644
--- a/.github/workflows/downstream-ci.yml
+++ b/.github/workflows/downstream-ci.yml
@@ -47,12 +47,12 @@ jobs:
REF=''
CORE_REF=''
- if [ "${{ github.event_name }}" = "pull_request" ]; then
- echo the workflow was triggered by a pull request targetting the dev or a release branch
+ if [ "${{ github.event_name }}" = "pull_request_target" ]; then
+ echo The workflow was triggered by a pull request targetting the dev or a release branch
REF="${{ github.base_ref }}"
CORE_REF="${{ github.event.pull_request.head.ref }}"
else
- echo the workflow was triggered by a push to the dev or a release branch
+ echo The workflow was triggered by a push to the dev or a release branch
REF="${{ github.ref_name }}"
CORE_REF="$REF"
fi
@@ -63,8 +63,23 @@ jobs:
fi
PAYLOAD=$(printf '{"ref": "%s", "inputs": {"core_ref": "%s"}}' "$REF" "$CORE_REF")
+ OUTPUT_FILE=/tmp/request-output
- curl -i --fail-with-body -H"authorization: Bearer $TOKEN" \
- -XPOST -H"Accept: application/vnd.github.v3+json" \
- https://api.github.com/repos/$REPOSITORY/actions/workflows/$WORKFLOW_ID/dispatches \
- -d "$PAYLOAD"
+ echo "Triggering $WORKFLOW_ID workflow on $REPOSITORY branch '$REF', which will check out core branch '$CORE_REF'"
+
+ status=$(
+ curl -i --fail-with-body -s -o $OUTPUT_FILE -w "%{http_code}" \
+ -H"authorization: Bearer $TOKEN" -H"Accept: application/vnd.github.v3+json" \
+ -XPOST \
+ -d "$PAYLOAD" \
+ https://api.github.com/repos/$REPOSITORY/actions/workflows/$WORKFLOW_ID/dispatches
+ )
+
+ if [ "$status" = "204" ]; then
+ echo Downstream workflow triggered successfully
+ else
+ echo Failed to trigger downstream workflow:
+ echo
+ cat $OUTPUT_FILE
+ exit 1
+ fi