-
Notifications
You must be signed in to change notification settings - Fork 17
/
determine_check_mode.sh
executable file
·29 lines (25 loc) · 1.21 KB
/
determine_check_mode.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
set -euo pipefail
if [[ ${INPUT_DEBUG} == "true" ]]; then
set -x
fi
check_mode="${INPUT_CHECK_MODE}"
if [[ -z ${check_mode} ]]; then
if [[ ${GITHUB_EVENT_NAME} == "pull_request" || ${GITHUB_EVENT_NAME} == "pull_request_target" ]]; then
check_mode="pull_request"
elif [[ ${GITHUB_EVENT_NAME} == "push" && (${GITHUB_REF_NAME} == trunk-merge/* || ${GITHUB_REF_NAME} == trunk-merge-beta/*) ]]; then
check_mode="trunk_merge"
elif [[ ${GITHUB_EVENT_NAME} == "push" ]]; then
check_mode="push"
elif [[ ${GITHUB_EVENT_NAME} == "workflow_dispatch" && (${GITHUB_REF_NAME} == trunk-merge/* || ${GITHUB_REF_NAME} == trunk-merge-beta/*) ]]; then
check_mode="trunk_merge"
elif [[ ${GITHUB_EVENT_NAME} == "workflow_dispatch" || ${GITHUB_EVENT_NAME} == "schedule" ]]; then
check_mode="all"
else
check_mode="none"
fi
elif [[ ${check_mode} != "all" && ${check_mode} != "none" && ${check_mode} != "populate_cache_only" && ${check_mode} != "pull_request" && ${check_mode} != "push" && ${check_mode} != "trunk_merge" ]]; then
echo "check-mode must be one of: 'all', 'none', 'populate_cache_only', 'pull_request', 'push', or 'trunk_merge'"
exit 1
fi
echo "TRUNK_CHECK_MODE=${check_mode}" >>"${GITHUB_ENV}"