TT-16103: trigger release to suggested branch after merge#127
TT-16103: trigger release to suggested branch after merge#127olamilekan000 wants to merge 1 commit into
Conversation
olamilekan000
commented
May 14, 2026
|
This PR enhances the Files Changed Analysis
Architecture & Impact Assessment
graph TD
subgraph "GitHub Actions: branch-suggestion.yml"
A[PR Merged Event] --> B{Is PR Merged?};
B -- Yes --> C[Job: analyze-and-suggest];
C -- saves results --> D[File: /tmp/results.json];
C --> E[Job: post-release-commands];
E -- reads results --> D;
E --> F[Execute post-release-commands.js];
end
subgraph "post-release-commands.js Script"
G[Start] --> H{Parse suggestion results};
H --> I{"Filter for 'required'/'recommended' branches"};
I --> J[For each target branch];
J --> K["Format '/release to <branch>' comment"];
K --> L[Post comment to PR via GitHub API];
end
F --> G;
L --> M((Downstream Release Workflow Triggered));
style A fill:#d4edda,stroke:#c3e6cb
style M fill:#d4edda,stroke:#c3e6cb
Scope Discovery & Context ExpansionThe changes are well-contained within the Metadata
Powered by Visor from Probelabs Last updated: 2026-05-14T17:31:29.143Z | Triggered by: pr_updated | Commit: 6b0bc76 💡 TIP: You can chat with Visor using |
Security Issues (1)
Architecture Issues (1)
Performance Issues (1)
Quality Issues (1)
Powered by Visor from Probelabs Last updated: 2026-05-14T17:29:58.199Z | Triggered by: pr_updated | Commit: 6b0bc76 💡 TIP: You can chat with Visor using |
988fc3c to
3089c6e
Compare
There was a problem hiding this comment.
The PR looks solid and correctly implements the automated release comments logic.
A few highlights:
- Idempotency: The use of
<!-- auto-release: <branch> -->markers ensures we don't post duplicate comments if the workflow is re-run. - Early Exits: Correctly skipping analysis when a PR is closed but not merged saves unnecessary API calls.
- Branch Filtering: Correctly filters out
masterand only targetsrequiredorrecommendedbranches.
Because this is a reusable workflow, updating the on.pull_request.types here to include closed is only half the puzzle.
For this to actually trigger when a PR is merged in the tyk repository, you will also need to update the caller workflow in the tyk repo (.github/workflows/intelligent-branch-recomendations.yml) to include the closed event type:
on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
- closed # <--- This must be added in the tyk repo!Great work on this!
3089c6e to
2b10608
Compare
2b10608 to
6b0bc76
Compare
| ); | ||
|
|
||
| for (const branch of targetBranches) { | ||
| const marker = `<!-- auto-release: ${branch} -->`; |
There was a problem hiding this comment.
If I understand the release bot correctly, it only accepts comments that match exactly:
https://github.com/TykTechnologies/github-actions/blob/main/.github/workflows/release-bot.yaml#L50
match(/^\/release to\s+([^\s]+)\s*$/i)
but the code here posts comments with an extra marker appended, so the final comment would be something like:
<!-- auto-release: release-5.8 -->
That won’t pass the release bot regex because the comment no longer ends after the branch name. We either need to make the release bot tolerate the marker, or avoid appending the marker to the command comment and detect duplicates another way.
There was a problem hiding this comment.
It's a comment to show that it was automatically added. The bot should still pick it up
There was a problem hiding this comment.
hmm, 🤔 I checked the call path again, and it looks like the marker is part of the actual comment body sent to GitHub:
const body = \/release to ${branch}\n\n${marker}`;`
and then:
await createPRComment(owner, repo, prNumber, body);
Since createPRComment sends that body as the issue comment, the release bot will receive the command plus the marker in the same comment. Without changing the release bot, could we post only the command itself and use exact command text for duplicate detection?
Are you able to test it? I might be wrong of course, but just want to be double sure :)
| @@ -53,6 +53,8 @@ jobs: | |||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |||
There was a problem hiding this comment.
I think this may be a blocker for the intended hand-off to the release bot.
If these /release to <branch> comments are created with the default GITHUB_TOKEN, GitHub will generally not trigger another workflow from the resulting issue_comment.created event. The release bot depends on that event, so the comment may be created successfully but the release workflow may not start.
GitHub documents this behavior here:
https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-when-your-workflow-runs/triggering-a-workflow
I think this needs to use a GitHub App token or PAT that is allowed to trigger the downstream workflow.
| ); | ||
| await createPRComment(owner, repo, prNumber, body); | ||
| console.log(`✅ Successfully posted release comment for ${branch}`); | ||
| } catch (error) { |
There was a problem hiding this comment.
Should this fail the workflow if posting release commands fails?
Right now errors are logged per branch, but the function continues and can finish successfully even if all required release comments failed to post. That would make the merge look like the release hand-off happened when it did not.
Could we collect failures and throw at the end, at least for required branches?
| // Collect all unique branches with priority 'required' or 'recommended' | ||
| const targetBranches = new Set(); | ||
| for (const result of matchResults) { | ||
| for (const branchMatch of result.branches) { |
There was a problem hiding this comment.
Small robustness point: this assumes every match result has a branches array. If the matcher ever returns a partial/malformed result, this will throw before posting any release commands.
Maybe we could we guard this with something like:
for (const branchMatch of result.branches || [])
or an Array.isArray(result.branches) check?