代码拉取完成,页面将自动刷新
#!/bin/bash -e
# Copyright 2021 Google Inc. Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
if [ -z "$PR_BRANCH" ]; then
# Remove the "refs/heads/" prefix
current_branch="${CURRENT_REF/refs\/heads\//}"
else
current_branch="$PR_BRANCH"
fi
if [[ "$current_branch" == feature.* ]]; then
default="$current_branch"
else
default="$DEFAULT_REF"
fi
if [[ -z "$default" ]]; then
skip="true"
else
skip="false"
fi
# We don't have a PR_BRANCH so we are not in a pull request, so there's no
# linked PR to find.
if [ -z "$PR_BRANCH" ]; then
if [[ -z "$default" ]]; then
echo "Not a pull request, skipping checkout"
else
echo "Not a pull request, using default ref $default"
fi
echo "skip=$skip" >> "$GITHUB_OUTPUT"
echo "ref=$default" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "::group::Pull request body"
echo "$PR_BODY"
echo "::endgroup::"
# Echoes the sass/sass Git ref that should be checked out for the current GitHub
# Actions run. If we're running specs for a pull request which refers to a
# sass/sass pull request, we'll run against the latter rather than sass/sass
# main.
echo "::group::Finding pull request reference"
for link in "$(echo "$PR_BODY" | grep -Eo "${REPO}(#|/pull/)[0-9]+")"; do
if [[ "$link" = *#* ]]; then
number="${link#*#}"
else
number="${link#*/pull/}"
fi
json="$(
curl --fail --silent \
--header "Authorization: token $TOKEN" \
--header "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/$REPO/pulls/${number}"
)"
if [[ "$?" == 0 && "$(echo "$json" | jq .state -r)" == "open" ]]; then
echo "Linked to pull request $number"
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "ref=refs/pull/$number/head" >> "$GITHUB_OUTPUT"
exit 0
else
echo "$link isn't a pull request."
fi
done
if [[ -z "$default" ]]; then
echo "No linked pull request, skipping checkout"
else
echo "No linked pull request, using default ref $default"
fi
echo "skip=$skip" >> "$GITHUB_OUTPUT"
echo "ref=$default" >> "$GITHUB_OUTPUT"
echo "::endgroup::"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。