Skip to content

Commit 071ddfb

Browse files
authored
open PR in Pinata when new cagent-version is released (#89)
Signed-off-by: Derek Misler <derek.misler@docker.com>
1 parent 9a695fb commit 071ddfb

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

.github/workflows/release.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
runs-on: ubuntu-latest
2727
outputs:
2828
version: ${{ steps.version.outputs.version }}
29+
sha: ${{ steps.release-commit.outputs.sha }}
2930

3031
steps:
3132
- name: Checkout code
@@ -164,6 +165,113 @@ jobs:
164165
165166
echo "Updated 'latest' tag to point to ${VERSION} ($RELEASE_SHA)"
166167
168+
update-pinata:
169+
name: Update pinata pr-review workflow
170+
needs: release
171+
if: success()
172+
runs-on: ubuntu-latest
173+
concurrency:
174+
group: update-pinata
175+
cancel-in-progress: false
176+
steps:
177+
- name: Generate GitHub App token
178+
id: app-token
179+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2
180+
with:
181+
app_id: ${{ secrets.CAGENT_REVIEWER_APP_ID }}
182+
private_key: ${{ secrets.CAGENT_REVIEWER_APP_PRIVATE_KEY }}
183+
repository: docker/pinata
184+
185+
- name: Checkout pinata
186+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
187+
with:
188+
repository: docker/pinata
189+
token: ${{ steps.app-token.outputs.token }}
190+
191+
- name: Update cagent-action reference
192+
id: update
193+
env:
194+
SHA: ${{ needs.release.outputs.sha }}
195+
VERSION: ${{ needs.release.outputs.version }}
196+
run: |
197+
FILE=".github/workflows/pr-review.yml"
198+
if [ ! -f "$FILE" ]; then
199+
echo "::error::$FILE not found in pinata"
200+
exit 1
201+
fi
202+
203+
if [ -z "$SHA" ] || [ -z "$VERSION" ]; then
204+
echo "::error::SHA or VERSION is empty (SHA='$SHA', VERSION='$VERSION')"
205+
exit 1
206+
fi
207+
208+
PATTERN='cagent-action/\.github/workflows/review-pr\.yml@[[:xdigit:]]\{40\} # v[0-9.]*'
209+
if ! grep -q "$PATTERN" "$FILE"; then
210+
echo "::error::Expected cagent-action reference pattern not found in $FILE — format may have changed"
211+
exit 1
212+
fi
213+
214+
sed -i "s|${PATTERN}|cagent-action/.github/workflows/review-pr.yml@${SHA} # ${VERSION}|" "$FILE"
215+
216+
if git diff --quiet "$FILE"; then
217+
echo "File already up to date, skipping."
218+
echo "skip=true" >> "$GITHUB_OUTPUT"
219+
else
220+
echo "Updated reference to ${SHA} # ${VERSION}"
221+
echo "skip=false" >> "$GITHUB_OUTPUT"
222+
fi
223+
224+
- name: Create or update PR
225+
if: steps.update.outputs.skip != 'true'
226+
env:
227+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
228+
VERSION: ${{ needs.release.outputs.version }}
229+
SHA: ${{ needs.release.outputs.sha }}
230+
run: |
231+
BRANCH="auto/update-cagent-action"
232+
RELEASE_URL="https://github.com/docker/cagent-action/releases/tag/$VERSION"
233+
234+
git config user.name "docker-agent[bot]"
235+
git config user.email "259137750+docker-agent[bot]@users.noreply.github.com"
236+
237+
git checkout -B "$BRANCH"
238+
git add .github/workflows/pr-review.yml
239+
git commit -m "chore: update cagent-action to $VERSION"
240+
241+
# Force-push to handle both new and existing branches.
242+
# This branch is exclusively managed by this workflow, so --force is safe.
243+
git push --force origin "$BRANCH"
244+
245+
EXISTING_PR=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')
246+
247+
PR_BODY="$(cat <<EOF
248+
## Summary
249+
Updates \`cagent-action\` reference in \`pr-review.yml\` to [$VERSION]($RELEASE_URL).
250+
- **Commit**: \`${SHA}\`
251+
- **Version**: \`${VERSION}\`
252+
> Auto-generated by the [release](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) workflow.
253+
254+
/skip-builds
255+
/skip-tests
256+
EOF
257+
)"
258+
259+
if [ -n "$EXISTING_PR" ]; then
260+
echo "Updating existing PR #$EXISTING_PR"
261+
gh pr edit "$EXISTING_PR" \
262+
--title "chore: update cagent-action to $VERSION" \
263+
--body "$PR_BODY" \
264+
--add-reviewer "derekmisler"
265+
else
266+
echo "Creating new PR"
267+
gh pr create \
268+
--title "chore: update cagent-action to $VERSION" \
269+
--body "$PR_BODY" \
270+
--label "team/gordon" \
271+
--label "merge/auto" \
272+
--reviewer "derekmisler"
273+
fi
274+
167275
publish-agent:
168276
name: Push review-pr agent to Docker Hub
169277
needs: release

review-pr/agents/pr-review-feedback.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version: "6"
2+
13
models:
24
haiku:
35
provider: anthropic

review-pr/agents/pr-review-reply.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version: "6"
2+
13
models:
24
sonnet:
35
provider: anthropic

review-pr/agents/pr-review.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version: "6"
2+
13
models:
24
sonnet:
35
provider: anthropic

0 commit comments

Comments
 (0)