Skip to content

Commit 65a58f6

Browse files
committed
Only run preview-build for elastic org members
1 parent 377ddc0 commit 65a58f6

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

.github/workflows/preview-build.yml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,40 @@ permissions:
5050
contents: read
5151
pull-requests: read
5252

53+
concurrency:
54+
group: ${{ github.workflow }}-${{ github.event.pull_request.head.ref || github.ref }}
55+
cancel-in-progress: ${{ startsWith(github.event_name, 'pull_request') }}
56+
5357
jobs:
58+
59+
60+
check:
61+
if: github.event.repository.fork == false # Skip running the job on the fork itself (It still runs on PRs on the upstream from forks)
62+
runs-on: ubuntu-latest
63+
env:
64+
AUTHOR_ASSOCIATION: ${{ github.event.pull_request.author_association }}
65+
steps:
66+
- run: |
67+
case "${GITHUB_EVENT_NAME}" in
68+
"pull_request" | "pull_request_target")
69+
if [[ "${AUTHOR_ASSOCIATION}" == "MEMBER" ]]; then
70+
exit 0;
71+
else
72+
echo "::error::You must be a member of the elastic organization to trigger a preview build. Please ask a member of the elastic organization to re-trigger the build.";
73+
exit 1;
74+
;;
75+
"push" | "workflow_dispatch")
76+
exit 0;
77+
;;
78+
*)
79+
echo "Unsupported event: '${GITHUB_EVENT_NAME}'";
80+
exit 1;
81+
;;
82+
esac
83+
5484
match:
5585
if: github.event.repository.fork == false # Skip running the job on the fork itself (It still runs on PRs on the upstream from forks)
56-
concurrency:
57-
group: ${{ github.workflow }}-${{ github.event.pull_request.head.ref || github.ref }}
58-
cancel-in-progress: ${{ startsWith(github.event_name, 'pull_request') }}
86+
needs: check
5987
runs-on: ubuntu-latest
6088
outputs:
6189
content-source-match: ${{ steps.event-check.outputs.content-source-match != '' && steps.event-check.outputs.content-source-match || steps.match.outputs.content-source-match }}

0 commit comments

Comments
 (0)