Skip to content

Commit 862b968

Browse files
authored
Merge pull request #563 from product-os/kyle/reject-duplicate-workflows
Reject duplicate workflow calls
2 parents 994e85f + c5ccd8b commit 862b968

File tree

2 files changed

+53
-57
lines changed

2 files changed

+53
-57
lines changed

.github/workflows/flowzone.yml

Lines changed: 32 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flowzone.yml

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -265,17 +265,6 @@
265265
echo "static=false" >> $GITHUB_OUTPUT
266266
fi
267267
268-
- &isJsonArray
269-
name: Check if INPUT is a JSON array
270-
id: is_json_array
271-
run: |
272-
if echo "${INPUT}" | jq 'type == "array"' | grep -q true
273-
then
274-
echo "result=true" >> $GITHUB_OUTPUT
275-
else
276-
echo "result=false" >> $GITHUB_OUTPUT
277-
fi
278-
279268
- &jsonArrayBuilder
280269
name: Build JSON array from comma-separated list
281270
id: to_json_array
@@ -345,6 +334,16 @@
345334
exit 1
346335
fi
347336
337+
- &rejectExternalPullRequest
338+
name: Reject external pull_request events
339+
if: |
340+
github.event_name == 'pull_request' &&
341+
github.event.pull_request.head.repo.full_name != github.repository
342+
run: |
343+
echo "::error:External workflows can not be used with `pull_request` events. \
344+
Please contact a member of the organization for assistance."
345+
exit 1
346+
348347
name: Flowzone
349348

350349
on:
@@ -689,18 +688,14 @@ jobs:
689688
timeout-minutes: ${{ fromJSON(inputs.jobs_timeout_minutes) }}
690689
if: |
691690
(
692-
(
693-
github.event_name == 'pull_request' &&
694-
github.event.pull_request.head.repo.full_name == github.repository
695-
) || (
696-
github.event_name == 'pull_request_target' &&
697-
github.event.pull_request.head.repo.full_name != github.repository
698-
)
691+
github.event_name == 'pull_request' ||
692+
github.event_name == 'pull_request_target'
699693
) && (
700694
github.event.action == 'opened' ||
701695
github.event.action == 'synchronize'
702696
)
703697
steps:
698+
- *rejectExternalPullRequest
704699
- *rejectConflictingSecrets
705700
- *rejectExternalWorkflowChanges
706701
- *logGitHubContext
@@ -712,18 +707,14 @@ jobs:
712707
timeout-minutes: ${{ fromJSON(inputs.jobs_timeout_minutes) }}
713708
if: |
714709
(
715-
(
716-
github.event_name == 'pull_request' &&
717-
github.event.pull_request.head.repo.full_name == github.repository
718-
) || (
719-
github.event_name == 'pull_request_target' &&
720-
github.event.pull_request.head.repo.full_name != github.repository
721-
)
710+
github.event_name == 'pull_request' ||
711+
github.event_name == 'pull_request_target'
722712
) && (
723713
github.event.action == 'closed' &&
724714
github.event.pull_request.merged == false
725715
)
726716
steps:
717+
- *rejectExternalPullRequest
727718
- *rejectConflictingSecrets
728719
- *rejectExternalWorkflowChanges
729720
- *logGitHubContext
@@ -734,18 +725,14 @@ jobs:
734725
timeout-minutes: ${{ fromJSON(inputs.jobs_timeout_minutes) }}
735726
if: |
736727
(
737-
(
738-
github.event_name == 'pull_request' &&
739-
github.event.pull_request.head.repo.full_name == github.repository
740-
) || (
741-
github.event_name == 'pull_request_target' &&
742-
github.event.pull_request.head.repo.full_name != github.repository
743-
)
728+
github.event_name == 'pull_request' ||
729+
github.event_name == 'pull_request_target'
744730
) && (
745731
github.event.action == 'closed' &&
746732
github.event.pull_request.merged == true
747733
)
748734
steps:
735+
- *rejectExternalPullRequest
749736
- *rejectConflictingSecrets
750737
- *rejectExternalWorkflowChanges
751738
- *logGitHubContext
@@ -3058,7 +3045,7 @@ jobs:
30583045
- custom_test
30593046
if: |
30603047
always() &&
3061-
needs.is_pr_open.result == 'success'
3048+
needs.is_pr_open.result != 'skipped'
30623049
steps:
30633050
- *rejectFailedJobs
30643051
- *rejectCancelledJobs
@@ -3090,7 +3077,7 @@ jobs:
30903077
- protect_branch
30913078
if: |
30923079
always() &&
3093-
needs.is_pr_open.result == 'success'
3080+
needs.is_pr_open.result != 'skipped'
30943081
steps:
30953082
- *rejectFailedJobs
30963083
- *rejectCancelledJobs

0 commit comments

Comments
 (0)