-
Notifications
You must be signed in to change notification settings - Fork 0
Add upstream change monitoring workflow with daily notifications to @sharpninja #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,124 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| name: Monitor Upstream Changes | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| schedule: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - cron: '0 8 * * *' # Run daily at 08:00 UTC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| workflow_dispatch: # Allow manual triggering | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||||||||||||||||||||
| issues: write | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| check-upstream: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Checkout fork | ||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| fetch-depth: 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Fetch upstream | ||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| git remote add upstream https://github.com/microsoft/graphrag.git | ||||||||||||||||||||||||||||||||||||||||||||||||||
| git fetch upstream main | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Compute outstanding changes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| COUNT=$(git rev-list --count HEAD..upstream/main 2>/dev/null || echo "0") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "$COUNT" > /tmp/commit-count.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||
| git log --oneline --no-merges -50 HEAD..upstream/main > /tmp/commit-list.txt 2>/dev/null || true | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+31
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Create or update tracking issue | ||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/github-script@v7 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| script: | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const fs = require('fs'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| const count = parseInt(fs.readFileSync('/tmp/commit-count.txt', 'utf8').trim(), 10); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const rawList = fs.readFileSync('/tmp/commit-list.txt', 'utf8').trim(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // Ensure the tracking label exists | ||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| await github.rest.issues.getLabel({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| owner: context.repo.owner, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| repo: context.repo.repo, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| name: 'upstream-tracking', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| await github.rest.issues.createLabel({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| owner: context.repo.owner, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| repo: context.repo.repo, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| name: 'upstream-tracking', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| color: '0075ca', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| description: 'Tracks outstanding changes from the upstream microsoft/graphrag repository', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+49
to
+56
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch { | |
| await github.rest.issues.createLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| name: 'upstream-tracking', | |
| color: '0075ca', | |
| description: 'Tracks outstanding changes from the upstream microsoft/graphrag repository', | |
| }); | |
| } catch (error) { | |
| if (error && error.status === 404) { | |
| await github.rest.issues.createLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| name: 'upstream-tracking', | |
| color: '0075ca', | |
| description: 'Tracks outstanding changes from the upstream microsoft/graphrag repository', | |
| }); | |
| } else { | |
| console.error('Failed to ensure upstream-tracking label exists:', error); | |
| throw error; | |
| } |
Copilot
AI
Feb 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison URL is incorrect. The format 'main...sharpninja:graphrag:main' compares the upstream main with the fork's main, but the direction is reversed. To show commits in upstream that aren't in the fork, it should be 'sharpninja:graphrag:main...microsoft:graphrag:main'. The three-dot syntax shows the symmetric difference, which may not be what's intended. Consider using 'sharpninja:graphrag:main..microsoft:graphrag:main' with two dots to show commits in upstream not in the fork.
| 'https://github.com/microsoft/graphrag/compare/main...sharpninja:graphrag:main'; | |
| 'https://github.com/microsoft/graphrag/compare/sharpninja:graphrag:main..microsoft:graphrag:main'; |
Copilot
AI
Feb 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment mentions "@sharpninja" will receive a notification on each run, but the issue body on line 69 also contains "@sharpninja". This means the notification will be triggered both when the issue is created AND when it's updated (via the body update), in addition to the comment. Consider removing "@sharpninja" from the body to avoid duplicate notifications on updates.
Copilot
AI
Feb 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow will create a new comment on every run (including when count is 0), which could generate unnecessary notifications. Consider only adding a comment when the count has changed or when there are actually outstanding changes. You could store the previous count in the issue body or check if the issue body has already been updated today.
| // Add a comment so @sharpninja receives a new notification | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| body: | |
| `@sharpninja **Update ${now}**: ` + | |
| `**${count}** outstanding change(s) from upstream detected.\n\n` + | |
| `[View full comparison](${comparisonUrl})`, | |
| }); | |
| // Only add a comment (and generate a notification) when there are outstanding changes | |
| if (count > 0) { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| body: | |
| `@sharpninja **Update ${now}**: ` + | |
| `**${count}** outstanding change(s) from upstream detected.\n\n` + | |
| `[View full comparison](${comparisonUrl})`, | |
| }); | |
| } else { | |
| console.log('No outstanding upstream changes; skipping notification comment.'); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
git remote add upstreamcommand will fail on subsequent runs because the remote will already exist. This should usegit remote add upstream ... || trueor check if the remote exists first, or usegit remote set-url upstream ...after checking.