Skip to content

Commit d9bb6dd

Browse files
committed
ci(align-deps): generate and post summary comment
1 parent f76268d commit d9bb6dd

3 files changed

Lines changed: 56 additions & 3 deletions

File tree

.changeset/wet-bushes-fry.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/workflows/align-deps.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ env:
1010
jobs:
1111
update:
1212
name: "Update `microsoft/react-native` preset"
13-
permissions: {}
13+
permissions:
14+
contents: read
15+
copilot-requests: write
1416
if: ${{ github.repository == 'microsoft/rnx-kit' }}
1517
runs-on: ubuntu-24.04
1618
steps:
@@ -72,13 +74,32 @@ jobs:
7274
permission-contents: write
7375
permission-pull-requests: write
7476
- name: Create or update pull request
77+
id: create-pull-request
7578
if: ${{ steps.find-release-candidate.outputs.found != '' }}
76-
uses: peter-evans/create-pull-request@v7
79+
uses: peter-evans/create-pull-request@v8
7780
with:
7881
token: ${{ steps.app-token.outputs.token }}
7982
commit-message: "fix(align-deps): ${{ steps.changeset.outputs.message }}"
8083
branch: rnx-align-deps/main
8184
sign-commits: true
8285
title: "fix(align-deps): ${{ steps.changeset.outputs.message }}"
8386
body-path: packages/align-deps/update-profile.output.txt
84-
timeout-minutes: 15
87+
- name: Generate summary
88+
id: summary
89+
if: ${{ steps.create-pull-request.outputs.pull-request-number != '' }}
90+
env:
91+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
run: |
93+
scripts/github-comment.sh summary
94+
working-directory: packages/align-deps
95+
continue-on-error: true
96+
- name: Create or update summary comment
97+
if: ${{ steps.create-pull-request.outputs.pull-request-number != '' }}
98+
env:
99+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
100+
PR_NUMBER: ${{ steps.create-pull-request.outputs.pull-request-number }}
101+
run: |
102+
scripts/github-comment.sh post
103+
working-directory: packages/align-deps
104+
continue-on-error: true
105+
timeout-minutes: 20
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
MARKER='<!-- rnx-align-deps-copilot-summary -->'
3+
OUTPUT='profile-comment.output.md'
4+
PROMPT="Scan for changes between current and latest available version of dependencies in the table below and give me a list of all changes that might be related to supporting new React Native versions.\n\n$(cat update-profile.output.txt)"
5+
REPO="repos/${GITHUB_REPOSITORY}/issues"
6+
7+
case ${1-} in
8+
summary)
9+
echo "${MARKER}\n\n" > $OUTPUT
10+
npx --yes @github/copilot --prompt "${PROMPT}" --silent --no-ask-user --allow-tool='shell(git:*)' >> $OUTPUT
11+
;;
12+
13+
post)
14+
comment_id="$(
15+
gh api --paginate "${REPO}/${PR_NUMBER}/comments" \
16+
--jq ".[] | select(.body | startswith(\"${MARKER}\")) | .id" |
17+
head -n 1
18+
)"
19+
20+
if [[ -n "$comment_id" ]]; then
21+
gh api --method PATCH "${REPO}/comments/${comment_id}" --field body=@$OUTPUT
22+
else
23+
gh api --method POST "${REPO}/${PR_NUMBER}/comments" --field body=@$OUTPUT
24+
fi
25+
;;
26+
27+
*)
28+
echo "usage: $0 [summary|post]"
29+
;;
30+
esac

0 commit comments

Comments
 (0)