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

allow external PRs to trigger SaaS tests

Markus Kahl9b02725e236a
diff --git a/.github/workflows/downstream-ci.yml b/.github/workflows/downstream-ci.yml
index d133d1c71e2..3a3419dc8df 100644
--- a/.github/workflows/downstream-ci.yml
+++ b/.github/workflows/downstream-ci.yml
@@ -3,12 +3,17 @@ on:
push:
branches:
- dev
- - release/*
+ - 'release/**'
paths-ignore:
- 'docs/**'
- 'help/**'
- pull_request:
+ # We run this in the less privileged mode to allow external PRs to use this workflow.
+ # This means the workflow will be executed on the base branch, making sure only our own workflow logic is used.
+ pull_request_target:
types: [opened, reopened, synchronize]
+ branches:
+ - dev
+ - 'release/**'
paths-ignore:
- 'docs/**'
- 'help/**'
@@ -38,7 +43,21 @@ jobs:
# * the name of the core branch that has to be checked out downstream to run the tests
# * that is either dev, release/16.1 (for instance), or the pull request's branch name
run: |
- if [[ ! "${{ github.base_ref || github.ref_name }}" =~ dev|release/.+ ]]; then
+ echo Triggering downstream workflow
+ 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
+ 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
+ REF="${{ github.ref_name }}"
+ CORE_REF="$REF"
+ fi
+
+ if [[ ! "$REF" =~ dev|release/.+ ]]; then
echo "Base branch is not dev or release branch. Cannot check downstream tests."
exit 0
fi
@@ -46,4 +65,4 @@ jobs:
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 '{"ref": "${{ github.base_ref || github.ref_name }}", "inputs": { "core_ref" : "${{ github.ref_name }}" }}'
+ -d '{"ref": "$REF", "inputs": { "core_ref" : "$CORE_REF" }}'