Skip to content

Commit 9c91aeb

Browse files
committed
ci: gate FearlessKeys in GH Actions
- Disable private pod when GH_READ_TOKEN is absent in GitHub Actions or Jenkins PRs - Use provided GH token (GH_PAT_READ or GH_READ_TOKEN) to rewrite GitHub URLs - Keeps Jenkins behavior; extends to GH Actions for parity Signed-off-by: William Richter <[email protected]>
1 parent fd36b0b commit 9c91aeb

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

scripts/ci/bootstrap.sh

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,34 @@ pushd "$WORKSPACE_DIR" >/dev/null
1414

1515
# 1) CocoaPods install (with fallbacks)
1616
if [[ -f Podfile ]]; then
17-
IS_PR=0
18-
if [[ -n "${CHANGE_ID:-}" ]]; then IS_PR=1; fi
17+
IS_JENKINS_PR=0
18+
if [[ -n "${CHANGE_ID:-}" ]]; then IS_JENKINS_PR=1; fi
1919

20-
# Handle private pods (FearlessKeys)
21-
if [[ "$IS_PR" == "1" && -z "${INCLUDE_FEARLESS_KEYS:-}" ]]; then
20+
# Determine token availability from either Jenkins or GitHub Actions
21+
GH_TOKEN_SRC=""
22+
if [[ -n "${GH_PAT_READ:-}" ]]; then GH_TOKEN_SRC="$GH_PAT_READ"; fi
23+
if [[ -z "$GH_TOKEN_SRC" && -n "${GH_READ_TOKEN:-}" ]]; then GH_TOKEN_SRC="$GH_READ_TOKEN"; fi
24+
25+
# Handle private pods (FearlessKeys) across CI providers
26+
SHOULD_DISABLE_KEYS=0
27+
if [[ -z "${INCLUDE_FEARLESS_KEYS:-}" ]]; then
28+
# Jenkins PRs without explicit opt-in
29+
if [[ "$IS_JENKINS_PR" == "1" && -z "$GH_TOKEN_SRC" ]]; then SHOULD_DISABLE_KEYS=1; fi
30+
# GitHub Actions PRs (secrets absent on forks)
31+
if [[ -n "${GITHUB_ACTIONS:-}" && -z "$GH_TOKEN_SRC" ]]; then SHOULD_DISABLE_KEYS=1; fi
32+
fi
33+
34+
if [[ "$SHOULD_DISABLE_KEYS" == "1" ]]; then
2235
if /usr/bin/grep -q "pod 'FearlessKeys'" Podfile; then
2336
cp Podfile Podfile.ci.bak
24-
awk 'BEGIN{done=0} { if(done==0 && $0 ~ /^[[:space:]]*pod '\''FearlessKeys'\''/){ print "# CI PR: disabled "$0; done=1 } else { print } }' Podfile > Podfile.ci.tmp && mv Podfile.ci.tmp Podfile
25-
echo "[bootstrap] Disabled FearlessKeys pod for PR build"
37+
awk 'BEGIN{done=0} { if(done==0 && $0 ~ /^[[:space:]]*pod '\''FearlessKeys'\''/){ print "# CI: disabled private pod for PR build -> "$0; done=1 } else { print } }' Podfile > Podfile.ci.tmp && mv Podfile.ci.tmp Podfile
38+
echo "[bootstrap] Disabled FearlessKeys pod (no token available in CI)"
2639
fi
2740
else
28-
# Trusted branch: enable tokens for private repos if provided
29-
if [[ -n "${GH_PAT_READ:-}" ]]; then
30-
git config --global url."https://${GH_PAT_READ}@github.com/".insteadOf "https://github.com/" || true
41+
# Trusted branch or token provided: enable tokens for private repos
42+
if [[ -n "$GH_TOKEN_SRC" ]]; then
43+
git config --global url."https://${GH_TOKEN_SRC}@github.com/".insteadOf "https://github.com/" || true
44+
echo "[bootstrap] Configured GitHub token for private pods"
3145
fi
3246
export INCLUDE_FEARLESS_KEYS=1
3347
fi

0 commit comments

Comments
 (0)