Branch matching support for forked repository on GitHub actions
This commit is contained in:
parent
2d9e97a3e1
commit
ca5f8f97bb
1 changed files with 8 additions and 2 deletions
|
@ -36,13 +36,19 @@ else
|
||||||
head=$(curl $apiEndpoint | jq -r '.head.label')
|
head=$(curl $apiEndpoint | jq -r '.head.label')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If head is set, it will contain either:
|
# If head is set, it will contain on BuilKite either:
|
||||||
# * "branch" when the author's branch and target branch are in the same repo
|
# * "branch" when the author's branch and target branch are in the same repo
|
||||||
# * "fork:branch" when the author's branch is in their fork or if this is a Netlify build
|
# * "fork:branch" when the author's branch is in their fork or if this is a Netlify build
|
||||||
# We can split on `:` into an array to check.
|
# We can split on `:` into an array to check.
|
||||||
|
# For GitHub Actions we need to inspect GITHUB_REPOSITORY and GITHUB_ACTOR
|
||||||
|
# to determine whether the branch is from a fork or not
|
||||||
BRANCH_ARRAY=(${head//:/ })
|
BRANCH_ARRAY=(${head//:/ })
|
||||||
if [[ "${#BRANCH_ARRAY[@]}" == "1" ]]; then
|
if [[ "${#BRANCH_ARRAY[@]}" == "1" ]]; then
|
||||||
|
if [[ "$GITHUB_REPOSITORY" = "$deforg/$defrepo" ]]; then
|
||||||
clone $deforg $defrepo $head
|
clone $deforg $defrepo $head
|
||||||
|
else
|
||||||
|
clone $GITHUB_ACTOR $defrepo $head
|
||||||
|
fi
|
||||||
elif [[ "${#BRANCH_ARRAY[@]}" == "2" ]]; then
|
elif [[ "${#BRANCH_ARRAY[@]}" == "2" ]]; then
|
||||||
clone ${BRANCH_ARRAY[0]} $defrepo ${BRANCH_ARRAY[1]}
|
clone ${BRANCH_ARRAY[0]} $defrepo ${BRANCH_ARRAY[1]}
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue