Skip to content

Commit 7bec3e6

Browse files
Fix feature flag cleanup API key
Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent d09a90e commit 7bec3e6

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

.github/workflows/feature_flag_cleanup.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
* "date_enabled" - the date on which the feature flag was enabled by default
6464
* "enabling_commit" - the Git commit in which the feature flag was enabled by default
6565
* You are running as part of a GitHub automation and must not commit or push any changes. Another agent will process the file you produce.
66-
warp_api_key: ${{ secrets.WARP_API_KEY }}
66+
warp_api_key: ${{ secrets.OSS_WARP_API_KEY }}
6767
share: team
6868

6969
- name: Upload feature flag log
@@ -87,6 +87,33 @@ jobs:
8787
flag_name=""
8888
cargo_flag=""
8989
90+
find_existing_cleanup_pr() {
91+
local branch="$1"
92+
local error_log
93+
error_log="$(mktemp)"
94+
95+
for attempt in 1 2 3; do
96+
if gh api \
97+
--method GET \
98+
"repos/${{ github.repository }}/pulls" \
99+
-f state=open \
100+
-f "head=${{ github.repository_owner }}:$branch" \
101+
--jq '.[0].number // ""' 2>"$error_log"; then
102+
rm -f "$error_log"
103+
return 0
104+
fi
105+
106+
if [ "$attempt" = "3" ]; then
107+
cat "$error_log" >&2
108+
rm -f "$error_log"
109+
return 1
110+
fi
111+
112+
echo "PR lookup failed for $branch, retrying..." >&2
113+
sleep $((attempt * 5))
114+
done
115+
}
116+
90117
# Iterate flags in order (oldest first) and pick the first one that is not
91118
# excluded and does not already have an open cleanup PR. Sort by
92119
# date_enabled here rather than relying on the analysis agent to emit
@@ -101,7 +128,7 @@ jobs:
101128
fi
102129
103130
candidate_branch="oz-agent/cleanup-feature-flag-$candidate_flag"
104-
existing_pr="$(gh pr list --state open --head "$candidate_branch" --json number --jq '.[0].number')"
131+
existing_pr="$(find_existing_cleanup_pr "$candidate_branch")"
105132
if [ -n "$existing_pr" ] && [ "$existing_pr" != "null" ]; then
106133
echo "Skipping $candidate_flag: open cleanup PR #$existing_pr already exists on $candidate_branch"
107134
continue
@@ -178,7 +205,7 @@ jobs:
178205
179206
You are running as part of a GitHub automation that runs with a read-only token and will package your changes into a patch for a separate job to commit. Do not create a branch, do not commit, do not push, do not create a PR, and do not call `gh`. Leave your changes in the working tree only.
180207
share: team
181-
warp_api_key: ${{ secrets.WARP_API_KEY }}
208+
warp_api_key: ${{ secrets.OSS_WARP_API_KEY }}
182209

183210
- name: Generate cleanup patch
184211
env:

0 commit comments

Comments
 (0)