55 - cron : " 0 6 * * *" # Daily at 1am EST / 2am EDT
66 workflow_dispatch :
77
8- permissions :
9- contents : write
10- pull-requests : write
8+ env :
9+ BRANCH : automated/upgrade-halide-llvm
1110
1211jobs :
1312 upgrade :
14- runs-on : ubuntu-latest
13+ runs-on : ubuntu-slim
1514 steps :
15+ - uses : actions/create-github-app-token@v2
16+ id : app-token
17+ with :
18+ app-id : ${{ secrets.LLVM_UPDATER_ID }}
19+ private-key : ${{ secrets.LLVM_UPDATER_PRIVATE_KEY }}
20+
21+ - name : Get GitHub App user ID
22+ id : get-user-id
23+ run : echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
24+ env :
25+ GH_TOKEN : ${{ steps.app-token.outputs.token }}
26+
27+ - name : Configure git and environment
28+ run : |
29+ echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV"
30+ git config --global user.name "${{ steps.app-token.outputs.app-slug }}[bot]"
31+ git config --global user.email "${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com"
32+
1633 - uses : actions/checkout@v4
34+ with :
35+ ref : main
36+ token : ${{ steps.app-token.outputs.token }}
37+
38+ - name : Switch to existing PR branch if present
39+ id : branch
40+ run : |
41+ if gh pr view "$BRANCH" --json state -q .state 2>/dev/null | grep -q OPEN; then
42+ echo "pr-exists=true" >> "$GITHUB_OUTPUT"
43+ git fetch origin "$BRANCH"
44+ git checkout "$BRANCH"
45+ else
46+ echo "pr-exists=false" >> "$GITHUB_OUTPUT"
47+ # Delete stale remote branch (e.g. leftover from a merged PR)
48+ git push origin --delete "$BRANCH" 2>/dev/null || true
49+ git checkout -b "$BRANCH"
50+ fi
1751
1852 - uses : astral-sh/setup-uv@v5
1953
@@ -38,25 +72,16 @@ jobs:
3872
3973 - name : Create or update PR
4074 if : steps.diff.outputs.changed == 'true'
41- env :
42- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4375 run : |
44- BRANCH="automated/upgrade-halide-llvm"
4576 TITLE="Upgrade halide-llvm to ${{ steps.diff.outputs.versions }}"
4677
47- git config user.name "github-actions[bot]"
48- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
49- git checkout -B "$BRANCH"
5078 git add uv.lock
5179 git commit -m "$TITLE"
5280
53- # Update existing PR or create a new one
54- if gh pr view "$BRANCH" --json state -q .state 2>/dev/null | grep -q OPEN; then
55- git push -u origin "$BRANCH" --force-with-lease \
56- && gh pr edit "$BRANCH" --title "$TITLE"
81+ if [ "${{ steps.branch.outputs.pr-exists }}" = "true" ]; then
82+ git push -u origin "$BRANCH"
83+ gh pr edit "$BRANCH" --title "$TITLE"
5784 else
58- # Delete stale remote branch (e.g. leftover from a merged PR)
59- git push origin --delete "$BRANCH" 2>/dev/null || true
6085 git push -u origin "$BRANCH"
6186 gh pr create \
6287 --title "$TITLE" \
0 commit comments