11name : Buddy Bot
22
33on :
4+ # Rebase checkbox: fires instantly when a PR body is edited (e.g. checkbox ticked).
5+ # No polling needed — this replaces the old every-minute cron for rebase detection.
6+ pull_request :
7+ types : [edited]
8+
49 schedule :
5- # Check for rebase requests every 20 minutes
6- - cron : ' */20 * * * *'
710 # Update dependencies every 2 hours
811 - cron : ' 0 */2 * * *'
912 # Update dashboard 15 minutes after dependency updates (ensures updates are reflected)
5861 type : boolean
5962
6063env :
61- # For workflow file updates, you need a Personal Access Token with 'repo' and 'workflow' scopes
62- # Create a PAT at: https://github.com/settings/tokens
63- # Add it as a repository secret named 'BUDDY_BOT_TOKEN'
64- # If BUDDY_BOT_TOKEN is not available, falls back to GITHUB_TOKEN (limited permissions)
64+ # Use the built-in GITHUB_TOKEN for commits and PRs — contributions are attributed
65+ # to github-actions[bot] instead of a personal account.
66+ # BUDDY_BOT_TOKEN (a PAT with 'repo' and 'workflow' scopes) is only used when
67+ # workflow file updates are needed. Create one at: https://github.com/settings/tokens
6568 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6669 BUDDY_BOT_TOKEN : ${{ secrets.BUDDY_BOT_TOKEN }}
6770
@@ -73,10 +76,18 @@ permissions:
7376 checks : read
7477 statuses : read
7578
79+ # Serialize runs per ref so parallel scheduled + manual triggers don't race
80+ # on the same branches/PRs. cancel-in-progress: false lets the currently
81+ # running job finish cleanly instead of being killed mid-commit.
82+ concurrency :
83+ group : buddy-bot-${{ github.ref }}
84+ cancel-in-progress : false
85+
7686jobs :
7787 # Job to determine which jobs should run based on trigger
7888 determine-jobs :
7989 runs-on : ubuntu-latest
90+ timeout-minutes : 5
8091 outputs :
8192 run_check : ${{ steps.determine.outputs.run_check }}
8293 run_update : ${{ steps.determine.outputs.run_update }}
@@ -90,7 +101,23 @@ jobs:
90101 echo "run_update=false" >> $GITHUB_OUTPUT
91102 echo "run_dashboard=false" >> $GITHUB_OUTPUT
92103
93- if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
104+ if [ "${{ github.event_name }}" = "pull_request" ]; then
105+ # PR body was edited — check if it's a buddy-bot PR with rebase checkbox
106+ # Only run the check job (lightweight: just scans for the checkbox and rebases)
107+ ACTOR="${{ github.actor }}"
108+ BRANCH="${{ github.event.pull_request.head.ref }}"
109+
110+ # Skip if the edit was made by a bot (prevents cascade loops where
111+ # buddy-bot updates a PR body → fires edited event → re-triggers workflow)
112+ if [[ "$ACTOR" == *"[bot]"* ]] || [[ "$ACTOR" == "github-actions[bot]" ]] || [[ "$ACTOR" == "buddy-bot" ]]; then
113+ echo "ℹ️ Skipping — PR edit was made by bot actor: $ACTOR"
114+ elif [[ "$BRANCH" == buddy-bot/* ]]; then
115+ echo "run_check=true" >> $GITHUB_OUTPUT
116+ echo "ℹ️ buddy-bot PR edited by user — running rebase check for branch: $BRANCH"
117+ else
118+ echo "ℹ️ Non-buddy-bot PR edited — skipping (branch: $BRANCH)"
119+ fi
120+ elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
94121 JOB="${{ github.event.inputs.job || 'all' }}"
95122 if [ "$JOB" = "all" ] || [ "$JOB" = "check" ]; then
96123 echo "run_check=true" >> $GITHUB_OUTPUT
@@ -103,9 +130,7 @@ jobs:
103130 fi
104131 elif [ "${{ github.event_name }}" = "schedule" ]; then
105132 # Determine based on cron schedule
106- if [ "${{ github.event.schedule }}" = "5,25,45 * * * *" ]; then
107- echo "run_check=true" >> $GITHUB_OUTPUT
108- elif [ "${{ github.event.schedule }}" = "0 */2 * * *" ]; then
133+ if [ "${{ github.event.schedule }}" = "0 */2 * * *" ]; then
109134 echo "run_update=true" >> $GITHUB_OUTPUT
110135 elif [ "${{ github.event.schedule }}" = "15 */2 * * *" ]; then
111136 echo "run_dashboard=true" >> $GITHUB_OUTPUT
@@ -115,11 +140,12 @@ jobs:
115140 # Shared setup job for common dependencies
116141 setup :
117142 runs-on : ubuntu-latest
143+ timeout-minutes : 10
118144 needs : determine-jobs
119145 if : ${{ needs.determine-jobs.outputs.run_check == 'true' || needs.determine-jobs.outputs.run_update == 'true' || needs.determine-jobs.outputs.run_dashboard == 'true' }}
120146 steps :
121147 - name : Checkout repository
122- uses : actions/checkout@v6
148+ uses : actions/checkout@v4
123149 with :
124150 token : ${{ secrets.GITHUB_TOKEN }}
125151 fetch-depth : 0 # Fetch full history for rebasing
@@ -130,7 +156,7 @@ jobs:
130156
131157 - name : Setup PHP and Composer (if needed)
132158 if : ${{ hashFiles('composer.json') != '' }}
133- uses : shivammathur/setup-php@2.36.0
159+ uses : shivammathur/setup-php@v2
134160 with :
135161 php-version : ' 8.4'
136162 tools : composer
@@ -151,12 +177,13 @@ jobs:
151177 # Check job (handles both rebase requests and auto-closing PRs)
152178 check :
153179 runs-on : ubuntu-latest
180+ timeout-minutes : 30
154181 needs : [determine-jobs, setup]
155182 if : ${{ needs.determine-jobs.outputs.run_check == 'true' }}
156183
157184 steps :
158185 - name : Checkout repository
159- uses : actions/checkout@v6
186+ uses : actions/checkout@v4
160187 with :
161188 token : ${{ secrets.GITHUB_TOKEN }}
162189 fetch-depth : 0
@@ -221,7 +248,7 @@ jobs:
221248 echo "" >> $GITHUB_STEP_SUMMARY
222249
223250 if [ "${{ github.event_name }}" = "schedule" ]; then
224- echo "⏰ **Scheduled Check**: Automatically checks every 20 minutes " >> $GITHUB_STEP_SUMMARY
251+ echo "⏰ **Scheduled Check**: Automatically checks every minute " >> $GITHUB_STEP_SUMMARY
225252 else
226253 echo "🖱️ **Manual Check**: Manually triggered from Actions tab" >> $GITHUB_STEP_SUMMARY
227254 fi
@@ -232,12 +259,13 @@ jobs:
232259 # Dependency update job
233260 dependency-update :
234261 runs-on : ubuntu-latest
262+ timeout-minutes : 30
235263 needs : [determine-jobs, setup]
236264 if : ${{ needs.determine-jobs.outputs.run_update == 'true' }}
237265
238266 steps :
239267 - name : Checkout repository
240- uses : actions/checkout@v6
268+ uses : actions/checkout@v4
241269 with :
242270 token : ${{ secrets.GITHUB_TOKEN }}
243271 fetch-depth : 0
@@ -248,7 +276,7 @@ jobs:
248276
249277 - name : Setup PHP and Composer (if needed)
250278 if : ${{ hashFiles('composer.json') != '' }}
251- uses : shivammathur/setup-php@2.36.0
279+ uses : shivammathur/setup-php@v2
252280 with :
253281 php-version : ' 8.4'
254282 tools : composer
@@ -341,12 +369,13 @@ jobs:
341369 # Dashboard update job
342370 dashboard-update :
343371 runs-on : ubuntu-latest
372+ timeout-minutes : 15
344373 needs : [determine-jobs, setup, dependency-update]
345374 if : ${{ needs.determine-jobs.outputs.run_dashboard == 'true' && always() }}
346375
347376 steps :
348377 - name : Checkout repository
349- uses : actions/checkout@v6
378+ uses : actions/checkout@v4
350379 with :
351380 token : ${{ secrets.GITHUB_TOKEN }}
352381
0 commit comments