-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (128 loc) · 6.58 KB
/
track-upstream.yml
File metadata and controls
151 lines (128 loc) · 6.58 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Track gstack upstream
on:
schedule:
- cron: '0 9 * * 1' # Every Monday 9:00 UTC
workflow_dispatch:
permissions:
contents: write
issues: write
jobs:
check-upstream:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for new gstack commits
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
LAST_KNOWN=$(cat .upstream-sha 2>/dev/null | tr -d '\n' || echo "none")
LATEST=$(gh api repos/garrytan/gstack/commits/main --jq '.sha')
LATEST_SHORT=$(echo "$LATEST" | head -c 7)
LATEST_MSG=$(gh api repos/garrytan/gstack/commits/main --jq '.commit.message' | head -1)
echo "last_known=$LAST_KNOWN" >> "$GITHUB_OUTPUT"
echo "latest=$LATEST" >> "$GITHUB_OUTPUT"
echo "latest_short=$LATEST_SHORT" >> "$GITHUB_OUTPUT"
echo "latest_msg=$LATEST_MSG" >> "$GITHUB_OUTPUT"
if [ "$LAST_KNOWN" = "$LATEST" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No changes detected."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "Changes detected: $LAST_KNOWN -> $LATEST_SHORT"
if [ "$LAST_KNOWN" != "none" ]; then
COMMITS=$(gh api "repos/garrytan/gstack/compare/${LAST_KNOWN}...${LATEST}" \
--jq '[.commits[] | "- `" + (.sha | .[:7]) + "` " + (.commit.message | split("\n") | .[0])] | join("\n")' 2>/dev/null || echo "- Unable to fetch diff")
FILES=$(gh api "repos/garrytan/gstack/compare/${LAST_KNOWN}...${LATEST}" \
--jq '[.files[].filename] | map(select(test("^(plan-ceo|plan-eng|review|ship|qa|retro)/"))) | if length == 0 then "No skill files changed" else join("\n") end' 2>/dev/null || echo "- Unable to determine")
# Categorize changes
PROMPT_CHANGES=$(gh api "repos/garrytan/gstack/compare/${LAST_KNOWN}...${LATEST}" \
--jq '[.files[] | select(.filename | test("^(plan-ceo|plan-eng|review|ship|qa|retro)/")) | select(.patch // "" | test("(You are|## |### |\\*\\*|prompt|instruction|checklist|principle|workflow)", "i")) | .filename] | unique | if length == 0 then "None detected" else join("\n") end' 2>/dev/null || echo "Unable to analyze")
FORMAT_CHANGES=$(gh api "repos/garrytan/gstack/compare/${LAST_KNOWN}...${LATEST}" \
--jq '[.files[] | select(.filename | test("^(plan-ceo|plan-eng|review|ship|qa|retro)/")) | select((.patch // "" | test("(You are|## |### |\\*\\*|prompt|instruction|checklist|principle|workflow)", "i")) | not) | .filename] | unique | if length == 0 then "None detected" else join("\n") end' 2>/dev/null || echo "Unable to analyze")
else
COMMITS=$(gh api 'repos/garrytan/gstack/commits?per_page=10' \
--jq '[.[] | "- `" + (.sha | .[:7]) + "` " + (.commit.message | split("\n") | .[0])] | join("\n")')
FILES="First sync — review all skills"
PROMPT_CHANGES="First sync — review all"
FORMAT_CHANGES="First sync — review all"
fi
# Multi-line env vars
echo "COMMITS<<EOF" >> "$GITHUB_ENV"
echo "$COMMITS" >> "$GITHUB_ENV"
echo "EOF" >> "$GITHUB_ENV"
echo "FILES<<EOF" >> "$GITHUB_ENV"
echo "$FILES" >> "$GITHUB_ENV"
echo "EOF" >> "$GITHUB_ENV"
echo "PROMPT_CHANGES<<EOF" >> "$GITHUB_ENV"
echo "$PROMPT_CHANGES" >> "$GITHUB_ENV"
echo "EOF" >> "$GITHUB_ENV"
echo "FORMAT_CHANGES<<EOF" >> "$GITHUB_ENV"
echo "$FORMAT_CHANGES" >> "$GITHUB_ENV"
echo "EOF" >> "$GITHUB_ENV"
fi
- name: Ensure upstream label exists
if: steps.check.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh label create upstream --description "Upstream gstack changes" --color "1d76db" 2>/dev/null || true
- name: Open or update issue
if: steps.check.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
EXISTING=$(gh issue list --label upstream --state open --json number --jq '.[0].number // empty')
BODY="gstack has new commits since last sync.
**Latest:** \`${{ steps.check.outputs.latest_short }}\` ${{ steps.check.outputs.latest_msg }}
**Compare:** https://github.com/garrytan/gstack/compare/${{ steps.check.outputs.last_known }}...${{ steps.check.outputs.latest }}
### New commits
${COMMITS}
### Affected skill files
${FILES}
### Change analysis
**Prompt/logic changes** (likely need porting):
${PROMPT_CHANGES}
**Format-only changes** (likely safe to skip):
${FORMAT_CHANGES}
### Mapping
| gstack | kstack | Action needed? |
|--------|--------|----------------|
| plan-ceo-review | plan-product | Check diff |
| plan-eng-review | plan-eng | Check diff |
| review | code-review | Check diff |
| ship | ship | Check diff |
| qa / qa-only | qa | Check diff |
| retro | retro | Check diff |
| browse | N/A | Skip |
| setup-browser-cookies | N/A | Skip |
### Checklist
- [ ] Read the gstack diff
- [ ] Review prompt/logic changes above
- [ ] Adapt to Kiro CLI SKILL.md format (remove Go templates, Playwright, Greptile, slash commands)
- [ ] Update affected skills
- [ ] Run evals on changed skills
- [ ] Close this issue"
# Dedent
BODY=$(echo "$BODY" | sed 's/^ //')
if [ -n "$EXISTING" ]; then
gh issue comment "$EXISTING" --body "$BODY"
echo "Updated existing issue #$EXISTING"
else
gh issue create \
--title "Upstream: gstack updated (${{ steps.check.outputs.latest_short }})" \
--label "upstream" \
--body "$BODY"
echo "Created new upstream issue"
fi
- name: Update upstream SHA
if: steps.check.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "${{ steps.check.outputs.latest }}" > .upstream-sha
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .upstream-sha
git commit -m "chore: track upstream gstack ${{ steps.check.outputs.latest_short }}"
git push