This repository was archived by the owner on Jun 17, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Fix weekly upstream sync agentic workflow prompt #50
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -41,111 +41,77 @@ safe-outputs: | |||||
| noop: | ||||||
| report-as-issue: false | ||||||
| --- | ||||||
| # Weekly Upstream Sync Agentic Workflow | ||||||
| This document describes the `weekly-upstream-sync.yml` GitHub Actions workflow, which automates the detection of new changes in the official [Copilot SDK](https://github.com/github/copilot-sdk) and delegates the merge work to the Copilot coding agent. | ||||||
| # Weekly Upstream Sync | ||||||
|
|
||||||
| ## Overview | ||||||
| You are an automation agent that detects new upstream changes and creates GitHub issues. You do **NOT** perform any code merges, edits, or pushes. Do **NOT** invoke any skills (especially `agentic-merge-upstream`). Your only job is to check for changes and use safe-output tools to create or close issues. | ||||||
|
|
||||||
| The workflow runs on a **weekly schedule** (every Monday at 10:00 UTC) and can also be triggered manually. It does **not** perform the actual merge — instead, it detects upstream changes and creates a GitHub issue assigned to `copilot`, instructing the agent to follow the [agentic-merge-upstream](../prompts/agentic-merge-upstream.prompt.md) prompt to port the changes. | ||||||
| ## Instructions | ||||||
|
|
||||||
| The agent must also create the Pull Request with the label `upstream-sync`. This allows the workflow to track the merge progress and avoid creating duplicate issues if the agent is still working on a previous sync. | ||||||
| Follow these steps exactly: | ||||||
|
|
||||||
| ## Trigger | ||||||
| ### Step 1: Read `.lastmerge` | ||||||
|
|
||||||
| | Trigger | Schedule | | ||||||
| |---|---| | ||||||
| | `schedule` | Every Monday at 10:00 UTC (`0 10 * * 1`) | | ||||||
| | `workflow_dispatch` | Manual trigger from the Actions tab | | ||||||
| Read the file `.lastmerge` in the repository root. It contains the SHA of the last upstream commit that was merged into this Java SDK. | ||||||
|
|
||||||
| ## Workflow Steps | ||||||
| ### Step 2: Check for upstream changes | ||||||
|
|
||||||
| ### 1. Checkout repository | ||||||
| Clone the upstream repository and compare commits: | ||||||
|
|
||||||
| Checks out the repo to read the `.lastmerge` file, which contains the SHA of the last upstream commit that was merged into the Java SDK. | ||||||
|
|
||||||
| ### 2. Check for upstream changes | ||||||
|
|
||||||
| - Reads the last merged commit hash from `.lastmerge` | ||||||
| - Clones the upstream `github/copilot-sdk` repository | ||||||
| - Compares `.lastmerge` against upstream `HEAD` | ||||||
| - If they match: sets `has_changes=false` | ||||||
| - If they differ: counts new commits, generates a summary (up to 20 most recent), and sets outputs (`commit_count`, `upstream_head`, `last_merge`, `summary`) | ||||||
|
|
||||||
| ### 3. Close previous upstream-sync issues (when changes found) | ||||||
|
|
||||||
| **Condition:** `has_changes == true` | ||||||
| ```bash | ||||||
| LAST_MERGE=$(cat .lastmerge) | ||||||
| git clone --quiet https://github.com/github/copilot-sdk.git /tmp/gh-aw/agent/upstream | ||||||
| cd /tmp/gh-aw/agent/upstream | ||||||
| UPSTREAM_HEAD=$(git rev-parse HEAD) | ||||||
| ``` | ||||||
|
|
||||||
| Before creating a new issue, closes any existing open issues with the `upstream-sync` label. This prevents stale issues from accumulating when previous sync attempts were incomplete or superseded. Each closed issue receives a comment explaining it was superseded. | ||||||
| If `LAST_MERGE` equals `UPSTREAM_HEAD`, there are **no new changes**. Go to Step 3a. | ||||||
|
|
||||||
| ### 4. Close stale upstream-sync issues (when no changes found) | ||||||
| If they differ, count the new commits and generate a summary: | ||||||
|
|
||||||
| **Condition:** `has_changes == false` | ||||||
| ```bash | ||||||
| COMMIT_COUNT=$(git rev-list --count "$LAST_MERGE".."$UPSTREAM_HEAD") | ||||||
| SUMMARY=$(git log --oneline "$LAST_MERGE".."$UPSTREAM_HEAD" | head -20) | ||||||
| ``` | ||||||
|
|
||||||
| If the upstream is already up to date, closes any lingering open `upstream-sync` issues with a comment noting that no changes were detected. This handles the case where a previous issue was created but the changes were merged manually (updating `.lastmerge`) before the agent completed. | ||||||
| Go to Step 3b. | ||||||
|
|
||||||
| ### 5. Create issue and assign to Copilot | ||||||
| ### Step 3a: No changes detected | ||||||
|
|
||||||
| **Condition:** `has_changes == true` | ||||||
| 1. Search for any open issues with the `upstream-sync` label using the GitHub MCP tools. | ||||||
| 2. If there are open `upstream-sync` issues, close each one using the `close_issue` safe-output tool with a comment: "No new upstream changes detected. The Java SDK is up to date. Closing." | ||||||
| 3. Call the `noop` safe-output tool with message: "No new upstream changes since last merge (<LAST_MERGE>)." | ||||||
| 4. **Stop here.** Do not proceed further. | ||||||
|
|
||||||
| Creates a new GitHub issue with: | ||||||
| ### Step 3b: Changes detected | ||||||
|
|
||||||
| - **Title:** `Upstream sync: N new commits (YYYY-MM-DD)` | ||||||
| - **Label:** `upstream-sync` | ||||||
| - **Assignee:** `copilot` | ||||||
| - **Body:** Contains commit count, commit range links, a summary of recent commits, and a link to the merge prompt | ||||||
| 1. Search for any open issues with the `upstream-sync` label using the GitHub MCP tools. | ||||||
| 2. Close each existing open `upstream-sync` issue using the `close_issue` safe-output tool with a comment: "Superseded by a newer upstream sync check." | ||||||
| 3. Create a new issue using the `create_issue` safe-output tool with: | ||||||
| - **Title:** `Upstream sync: <COMMIT_COUNT> new commits (<YYYY-MM-DD>)` | ||||||
| - **Body:** Include the following information: | ||||||
| ``` | ||||||
| ## Automated Upstream Sync | ||||||
|
|
||||||
| The Copilot coding agent picks up the issue, creates a branch and PR, then follows the merge prompt to port the changes. | ||||||
| There are **<COMMIT_COUNT>** new commits in the [official Copilot SDK](https://github.com/github/copilot-sdk) since the last merge. | ||||||
|
|
||||||
| ### 6. Summary | ||||||
| - **Last merged commit:** [`<LAST_MERGE>`](https://github.com/github/copilot-sdk/commit/<LAST_MERGE>) | ||||||
| - **Upstream HEAD:** [`<UPSTREAM_HEAD>`](https://github.com/github/copilot-sdk/commit/<UPSTREAM_HEAD>) | ||||||
|
|
||||||
| Writes a GitHub Actions step summary with: | ||||||
| ### Recent upstream commits | ||||||
|
|
||||||
| - Whether changes were detected | ||||||
| - Commit count and range | ||||||
| - Recent upstream commits | ||||||
| - Link to the created issue (if any) | ||||||
| ``` | ||||||
| <SUMMARY> | ||||||
| ``` | ||||||
|
|
||||||
| ## Flow Diagram | ||||||
| ### Instructions | ||||||
|
|
||||||
| ``` | ||||||
| ┌─────────────────────┐ | ||||||
| │ Schedule / Manual │ | ||||||
| └──────────┬──────────┘ | ||||||
| │ | ||||||
| ▼ | ||||||
| ┌─────────────────────┐ | ||||||
| │ Read .lastmerge │ | ||||||
| │ Clone upstream SDK │ | ||||||
| │ Compare commits │ | ||||||
| └──────────┬──────────┘ | ||||||
| │ | ||||||
| ┌─────┴─────┐ | ||||||
| │ │ | ||||||
| changes? no changes | ||||||
| │ │ | ||||||
| ▼ ▼ | ||||||
| ┌──────────┐ ┌──────────────────┐ | ||||||
| │ Close old│ │ Close stale │ | ||||||
| │ issues │ │ issues │ | ||||||
| └────┬─────┘ └──────────────────┘ | ||||||
| │ | ||||||
| ▼ | ||||||
| ┌──────────────────────────┐ | ||||||
| │ Create issue assigned to │ | ||||||
| │ copilot │ | ||||||
| └──────────────────────────┘ | ||||||
| │ | ||||||
| ▼ | ||||||
| ┌──────────────────────────┐ | ||||||
| │ Agent follows prompt to │ | ||||||
| │ port changes → PR │ | ||||||
| └──────────────────────────┘ | ||||||
| ``` | ||||||
| Follow the [agentic-merge-upstream](.github/prompts/agentic-merge-upstream.prompt.md) prompt to port these changes to the Java SDK. | ||||||
| ``` | ||||||
| 4. After creating the issue, use the `assign_to_agent` safe-output tool to assign Copilot to the newly created issue. | ||||||
|
||||||
| 4. After creating the issue, use the `assign_to_agent` safe-output tool to assign Copilot to the newly created issue. | |
| 4. After creating the issue, use the `assign_to_agent` safe-output tool to assign Copilot to the newly created issue, passing the created issue's number from the `create_issue` output as `issue_number`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 link target
(.github/prompts/agentic-merge-upstream.prompt.md)is relative to this file’s directory, so on GitHub it resolves to.github/workflows/.github/prompts/...and is broken. Use a correct relative path (e.g.,../prompts/agentic-merge-upstream.prompt.md) or an absolute GitHub URL so the referenced prompt can be opened reliably from the created issue body/instructions.