Files
DroidDeck/.github/workflows/pr-release-sweep.yml
T
Kurt Himebauch 87c571f443 feat(updates): install any kept Preview build, link builds to their PR and commit, flag stale test builds (#2624)
* feat(updates): install any kept Preview build, link builds to their PR and commit, flag stale test builds

* fix(updates): address review of the Updates tab history and test-build watch

* fix(updates): notify on switch to a followed PR, keep higher-version rebuilds installable

* fix(ci): let full reruns replace every artifact, note only expired PR builds

* fix(ci): leave the rebuild note only when the PR build is too old to rerun

* fix(ci): poll unfinished PR builds together and queue version-bump runs

* fix(ci): also rebuild PR builds that were running when the versionCode changed

* fix(ci): rebuild fork and just-finished PR builds, recheck the PR head before a rerun

* fix(ci): fail the rebuild sweep when finding candidates fails

* fix(ci): time the bump from the rebuild run's creation and scan unfinished builds of any age

* fix(ci): check the latest build of every open PR instead of scanning run history

* fix(ci): count PR builds that finish between the version push and the rebuild run

* fix(ci): use the push time from the event as the rebuild boundary
2026-11-14 16:20:29 -05:00

64 lines
1.8 KiB
YAML

name: PR Release Sweep
run-name: sweep test builds of closed PRs
on:
schedule:
- cron: '17 */6 * * *'
workflow_dispatch:
permissions:
contents: read
pull-requests: read
concurrency:
group: pr-release-sweep
cancel-in-progress: false
jobs:
sweep:
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/create-github-app-token@v2
id: ci-token
with:
app-id: ${{ vars.DROIDDECK_CI_APP_ID }}
private-key: ${{ secrets.DROIDDECK_CI_APP_KEY }}
owner: Droid-Deck
repositories: DroidDeck-CI
- name: Delete test builds whose PR is no longer open
env:
CI_TOKEN: ${{ steps.ci-token.outputs.token }}
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
retry() {
for attempt in 1 2 3 4; do
"$@" && return 0
[ "$attempt" = 4 ] || sleep $((attempt * 20))
done
return 1
}
tags=$(GH_TOKEN="$CI_TOKEN" retry gh api --paginate "repos/Droid-Deck/DroidDeck-CI/releases?per_page=100" --jq '.[].tag_name' |
grep -E '^pr-[0-9]+(\.0)?$' || true)
failed=0
for tag in $tags; do
number=${tag#pr-}
number=${number%.0}
state=$(retry gh api "repos/$GITHUB_REPOSITORY/pulls/$number" --jq .state) || { failed=1; continue; }
if [ "$state" != open ]; then
if GH_TOKEN="$CI_TOKEN" retry gh release delete "$tag" -R Droid-Deck/DroidDeck-CI --yes --cleanup-tag; then
echo "Deleted $tag (PR #$number is $state)"
else
failed=1
fi
fi
done
exit "$failed"
catalog:
needs: sweep
if: ${{ always() }}
uses: ./.github/workflows/update-catalog.yml
secrets: inherit