-
Notifications
You must be signed in to change notification settings - Fork 17
/
push.sh
executable file
·47 lines (39 loc) · 1.23 KB
/
push.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# shellcheck disable=SC2086
set -euo pipefail
if [[ ${INPUT_DEBUG} == "true" ]]; then
set -x
fi
fetch() {
git -c protocol.version=2 fetch -q \
--no-tags \
--no-recurse-submodules \
"$@"
}
if [[ ${GITHUB_EVENT_BEFORE} == "0000000000000000000000000000000000000000" ]]; then
# Github will send us all 0s for the before hash in a few circumstances, such as the first commit to a repo
# or pushing a tag. In these instances we will check the whole repo.
"${TRUNK_PATH}" check \
--ci \
--all \
--github-commit "${GITHUB_EVENT_AFTER}" \
${INPUT_ARGUMENTS}
exit
fi
if [[ ${GITHUB_REF_NAME} == gh-readonly-queue/* ]]; then
# If we are running via the GH merge queue then we use HEAD^1 as the commit as github.event.before will be inaccurate.
head_sha=$(git rev-parse HEAD)
fetch --depth=2 origin "${head_sha}"
upstream=$(git rev-parse HEAD^1)
echo "Detected merge queue commit, using HEAD^1 (${upstream}) as upstream"
fi
if [[ -z ${upstream+x} ]]; then
# Otherwise use github.event.before as the upstream.
upstream="${GITHUB_EVENT_BEFORE}"
fetch origin "${upstream}"
fi
"${TRUNK_PATH}" check \
--ci \
--upstream "${upstream}" \
--github-commit "${GITHUB_EVENT_AFTER}" \
${INPUT_ARGUMENTS}