-
Notifications
You must be signed in to change notification settings - Fork 14
48 lines (46 loc) · 1.73 KB
/
refactor.yml
File metadata and controls
48 lines (46 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Trigger Refactor
on:
schedule:
- cron: '*/15 * * * *'
issues:
types: [opened, reopened, labeled]
workflow_dispatch:
jobs:
trigger:
runs-on: ubuntu-latest
timeout-minutes: 2
# Only trigger on issues with safe-to-work AND (bug, cli, enhancement, or maintenance) labels, or schedule/manual
if: >-
github.event_name != 'issues' ||
(contains(github.event.issue.labels.*.name, 'safe-to-work') &&
(contains(github.event.issue.labels.*.name, 'bug') ||
contains(github.event.issue.labels.*.name, 'cli') ||
contains(github.event.issue.labels.*.name, 'enhancement') ||
contains(github.event.issue.labels.*.name, 'maintenance')))
steps:
- name: Trigger refactor cycle
env:
SPRITE_URL: ${{ secrets.REFACTOR_SPRITE_URL }}
TRIGGER_SECRET: ${{ secrets.REFACTOR_TRIGGER_SECRET }}
run: |
HTTP_CODE=$(curl -sS --connect-timeout 15 --max-time 30 \
-o /tmp/response.json -w "%{http_code}" -X POST \
"${SPRITE_URL}/trigger?reason=${{ github.event_name }}&issue=${{ github.event.issue.number || '' }}" \
-H "Authorization: Bearer ${TRIGGER_SECRET}")
BODY=$(cat /tmp/response.json 2>/dev/null || echo '{}')
echo "$BODY"
case "$HTTP_CODE" in
2*)
echo "::notice::Trigger accepted (HTTP $HTTP_CODE)"
;;
409)
echo "::notice::Run already in progress — this is expected (HTTP 409)"
;;
429)
echo "::warning::Server at capacity (HTTP 429)"
;;
*)
echo "::error::Trigger failed (HTTP $HTTP_CODE)"
exit 1
;;
esac