mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-25 12:34:38 -07:00
migrate to patch both (#8803)
This commit is contained in:
@@ -73,7 +73,7 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
- name: 'Comment on Original PR'
|
- name: 'Comment on Original PR'
|
||||||
if: '!inputs.dry_run && inputs.original_pr'
|
if: 'inputs.original_pr'
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
ORIGINAL_PR: '${{ github.event.inputs.original_pr }}'
|
ORIGINAL_PR: '${{ github.event.inputs.original_pr }}'
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ jobs:
|
|||||||
commands: 'patch'
|
commands: 'patch'
|
||||||
permission: 'write'
|
permission: 'write'
|
||||||
issue-type: 'pull-request'
|
issue-type: 'pull-request'
|
||||||
static-args: |
|
|
||||||
dry_run=false
|
|
||||||
|
|
||||||
- name: 'Get PR Status'
|
- name: 'Get PR Status'
|
||||||
id: 'pr_status'
|
id: 'pr_status'
|
||||||
@@ -49,67 +47,80 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
github-token: '${{ secrets.GITHUB_TOKEN }}'
|
github-token: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
script: |
|
script: |
|
||||||
// Parse the comment body directly to extract channel
|
// Parse the comment body directly to extract channel(s)
|
||||||
const commentBody = process.env.COMMENT_BODY;
|
const commentBody = process.env.COMMENT_BODY;
|
||||||
console.log('Comment body:', commentBody);
|
console.log('Comment body:', commentBody);
|
||||||
|
|
||||||
let channel = 'stable'; // default
|
let channels = ['stable', 'preview']; // default to both
|
||||||
|
|
||||||
// Parse different formats:
|
// Parse different formats:
|
||||||
// /patch channel=preview
|
// /patch (defaults to both)
|
||||||
// /patch --channel preview
|
// /patch both
|
||||||
|
// /patch stable
|
||||||
// /patch preview
|
// /patch preview
|
||||||
if (commentBody.includes('channel=preview')) {
|
if (commentBody.trim() === '/patch' || commentBody.trim() === '/patch both') {
|
||||||
channel = 'preview';
|
channels = ['stable', 'preview'];
|
||||||
} else if (commentBody.includes('--channel preview')) {
|
} else if (commentBody.trim() === '/patch stable') {
|
||||||
channel = 'preview';
|
channels = ['stable'];
|
||||||
} else if (commentBody.trim() === '/patch preview') {
|
} else if (commentBody.trim() === '/patch preview') {
|
||||||
channel = 'preview';
|
channels = ['preview'];
|
||||||
}
|
} else {
|
||||||
|
// Fallback parsing for legacy formats
|
||||||
// Validate channel
|
if (commentBody.includes('channel=preview')) {
|
||||||
if (channel !== 'stable' && channel !== 'preview') {
|
channels = ['preview'];
|
||||||
throw new Error(`Invalid channel: ${channel}. Must be 'stable' or 'preview'.`);
|
} else if (commentBody.includes('--channel preview')) {
|
||||||
}
|
channels = ['preview'];
|
||||||
|
|
||||||
console.log('Detected channel:', channel);
|
|
||||||
|
|
||||||
const response = await github.rest.actions.createWorkflowDispatch({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
workflow_id: 'release-patch-1-create-pr.yml',
|
|
||||||
ref: 'main',
|
|
||||||
inputs: {
|
|
||||||
commit: '${{ steps.pr_status.outputs.MERGE_COMMIT_SHA }}',
|
|
||||||
channel: channel,
|
|
||||||
dry_run: 'false',
|
|
||||||
original_pr: '${{ github.event.issue.number }}'
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
// Wait a moment for the workflow to be created, then find it
|
console.log('Detected channels:', channels);
|
||||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
||||||
|
const dispatchedRuns = [];
|
||||||
|
|
||||||
|
// Dispatch workflow for each channel
|
||||||
|
for (const channel of channels) {
|
||||||
|
console.log(`Dispatching workflow for channel: ${channel}`);
|
||||||
|
|
||||||
|
const response = await github.rest.actions.createWorkflowDispatch({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
workflow_id: 'release-patch-1-create-pr.yml',
|
||||||
|
ref: 'main',
|
||||||
|
inputs: {
|
||||||
|
commit: '${{ steps.pr_status.outputs.MERGE_COMMIT_SHA }}',
|
||||||
|
channel: channel,
|
||||||
|
original_pr: '${{ github.event.issue.number }}'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatchedRuns.push({ channel, response });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait a moment for the workflows to be created
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||||
|
|
||||||
const runs = await github.rest.actions.listWorkflowRuns({
|
const runs = await github.rest.actions.listWorkflowRuns({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
workflow_id: 'release-patch-1-create-pr.yml',
|
workflow_id: 'release-patch-1-create-pr.yml',
|
||||||
per_page: 10
|
per_page: 20 // Increased to handle multiple runs
|
||||||
});
|
});
|
||||||
|
|
||||||
// Find the most recent run that matches our trigger
|
// Find the recent runs that match our trigger
|
||||||
const dispatchedRun = runs.data.workflow_runs.find(run =>
|
const recentRuns = runs.data.workflow_runs.filter(run =>
|
||||||
run.event === 'workflow_dispatch' &&
|
run.event === 'workflow_dispatch' &&
|
||||||
new Date(run.created_at) > new Date(Date.now() - 10000) // Within last 10 seconds
|
new Date(run.created_at) > new Date(Date.now() - 15000) // Within last 15 seconds
|
||||||
);
|
).slice(0, channels.length); // Limit to the number of channels we dispatched
|
||||||
|
|
||||||
if (dispatchedRun) {
|
// Set outputs
|
||||||
core.setOutput('dispatched_run_id', dispatchedRun.id);
|
core.setOutput('dispatched_channels', channels.join(','));
|
||||||
core.setOutput('dispatched_run_url', dispatchedRun.html_url);
|
core.setOutput('dispatched_run_count', channels.length.toString());
|
||||||
|
|
||||||
|
if (recentRuns.length > 0) {
|
||||||
|
core.setOutput('dispatched_run_urls', recentRuns.map(r => r.html_url).join(','));
|
||||||
|
core.setOutput('dispatched_run_ids', recentRuns.map(r => r.id).join(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
core.setOutput('channel', channel);
|
|
||||||
|
|
||||||
- name: 'Comment on Failure'
|
- name: 'Comment on Failure'
|
||||||
if: "startsWith(github.event.comment.body, '/patch') && steps.pr_status.outputs.STATE != 'MERGED'"
|
if: "startsWith(github.event.comment.body, '/patch') && steps.pr_status.outputs.STATE != 'MERGED'"
|
||||||
uses: 'peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d'
|
uses: 'peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d'
|
||||||
@@ -120,34 +131,36 @@ jobs:
|
|||||||
:x: The `/patch` command failed. This pull request must be merged before a patch can be created.
|
:x: The `/patch` command failed. This pull request must be merged before a patch can be created.
|
||||||
|
|
||||||
- name: 'Final Status Comment - Success'
|
- name: 'Final Status Comment - Success'
|
||||||
if: "always() && startsWith(github.event.comment.body, '/patch') && steps.dispatch_patch.outcome == 'success' && steps.dispatch_patch.outputs.dispatched_run_url"
|
if: "always() && startsWith(github.event.comment.body, '/patch') && steps.dispatch_patch.outcome == 'success' && steps.dispatch_patch.outputs.dispatched_run_urls"
|
||||||
uses: 'peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d'
|
uses: 'peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d'
|
||||||
with:
|
with:
|
||||||
token: '${{ secrets.GITHUB_TOKEN }}'
|
token: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
issue-number: '${{ github.event.issue.number }}'
|
issue-number: '${{ github.event.issue.number }}'
|
||||||
body: |
|
body: |
|
||||||
✅ **Patch workflow dispatched successfully!**
|
✅ **Patch workflow(s) dispatched successfully!**
|
||||||
|
|
||||||
**📋 Details:**
|
**📋 Details:**
|
||||||
- **Channel**: `${{ steps.dispatch_patch.outputs.channel }}`
|
- **Channels**: `${{ steps.dispatch_patch.outputs.dispatched_channels }}`
|
||||||
- **Commit**: `${{ steps.pr_status.outputs.MERGE_COMMIT_SHA }}`
|
- **Commit**: `${{ steps.pr_status.outputs.MERGE_COMMIT_SHA }}`
|
||||||
|
- **Workflows Created**: ${{ steps.dispatch_patch.outputs.dispatched_run_count }}
|
||||||
|
|
||||||
**🔗 Track Progress:**
|
**🔗 Track Progress:**
|
||||||
- [Dispatched patch workflow](${{ steps.dispatch_patch.outputs.dispatched_run_url }})
|
- [View patch workflows](https://github.com/${{ github.repository }}/actions/workflows/release-patch-1-create-pr.yml)
|
||||||
- [This workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
|
- [This workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
|
||||||
|
|
||||||
- name: 'Final Status Comment - Dispatch Success (No URL)'
|
- name: 'Final Status Comment - Dispatch Success (No URL)'
|
||||||
if: "always() && startsWith(github.event.comment.body, '/patch') && steps.dispatch_patch.outcome == 'success' && !steps.dispatch_patch.outputs.dispatched_run_url"
|
if: "always() && startsWith(github.event.comment.body, '/patch') && steps.dispatch_patch.outcome == 'success' && !steps.dispatch_patch.outputs.dispatched_run_urls"
|
||||||
uses: 'peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d'
|
uses: 'peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d'
|
||||||
with:
|
with:
|
||||||
token: '${{ secrets.GITHUB_TOKEN }}'
|
token: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
issue-number: '${{ github.event.issue.number }}'
|
issue-number: '${{ github.event.issue.number }}'
|
||||||
body: |
|
body: |
|
||||||
✅ **Patch workflow dispatched successfully!**
|
✅ **Patch workflow(s) dispatched successfully!**
|
||||||
|
|
||||||
**📋 Details:**
|
**📋 Details:**
|
||||||
- **Channel**: `${{ steps.dispatch_patch.outputs.channel }}`
|
- **Channels**: `${{ steps.dispatch_patch.outputs.dispatched_channels }}`
|
||||||
- **Commit**: `${{ steps.pr_status.outputs.MERGE_COMMIT_SHA }}`
|
- **Commit**: `${{ steps.pr_status.outputs.MERGE_COMMIT_SHA }}`
|
||||||
|
- **Workflows Created**: ${{ steps.dispatch_patch.outputs.dispatched_run_count }}
|
||||||
|
|
||||||
**🔗 Track Progress:**
|
**🔗 Track Progress:**
|
||||||
- [View patch workflows](https://github.com/${{ github.repository }}/actions/workflows/release-patch-1-create-pr.yml)
|
- [View patch workflows](https://github.com/${{ github.repository }}/actions/workflows/release-patch-1-create-pr.yml)
|
||||||
|
|||||||
+12
-6
@@ -110,12 +110,20 @@ There are two ways to create a patch pull request:
|
|||||||
|
|
||||||
After a pull request containing the fix has been merged, a maintainer can add a comment on that same PR with the following format:
|
After a pull request containing the fix has been merged, a maintainer can add a comment on that same PR with the following format:
|
||||||
|
|
||||||
`/patch <channel> [--dry-run]`
|
`/patch [channel]`
|
||||||
|
|
||||||
- **channel**: `stable` or `preview`
|
- **channel** (optional):
|
||||||
- **--dry-run** (optional): If included, the workflow will run in dry-run mode. This will create the PR with "[DRY RUN]" in the title, and merging it will trigger a dry run of the final release, so nothing is actually published.
|
- _no channel_ - patches both stable and preview channels (default, recommended for most fixes)
|
||||||
|
- `both` - patches both stable and preview channels (same as default)
|
||||||
|
- `stable` - patches only the stable channel
|
||||||
|
- `preview` - patches only the preview channel
|
||||||
|
|
||||||
Example: `/patch stable --dry-run`
|
Examples:
|
||||||
|
|
||||||
|
- `/patch` (patches both stable and preview - default)
|
||||||
|
- `/patch both` (patches both stable and preview - explicit)
|
||||||
|
- `/patch stable` (patches only stable)
|
||||||
|
- `/patch preview` (patches only preview)
|
||||||
|
|
||||||
The `Release: Patch from Comment` workflow will automatically find the merge commit SHA and trigger the `Release: Patch (1) Create PR` workflow. If the PR is not yet merged, it will post a comment indicating the failure.
|
The `Release: Patch from Comment` workflow will automatically find the merge commit SHA and trigger the `Release: Patch (1) Create PR` workflow. If the PR is not yet merged, it will post a comment indicating the failure.
|
||||||
|
|
||||||
@@ -134,8 +142,6 @@ This workflow will automatically:
|
|||||||
4. Cherry-pick your specified commit into the hotfix branch.
|
4. Cherry-pick your specified commit into the hotfix branch.
|
||||||
5. Create a pull request from the hotfix branch back to the release branch.
|
5. Create a pull request from the hotfix branch back to the release branch.
|
||||||
|
|
||||||
**Important:** If you select `stable`, the workflow will run twice, creating one PR for the `stable` channel and a second PR for the `preview` channel.
|
|
||||||
|
|
||||||
#### 2. Review and Merge
|
#### 2. Review and Merge
|
||||||
|
|
||||||
Review the automatically created pull request(s) to ensure the cherry-pick was successful and the changes are correct. Once approved, merge the pull request.
|
Review the automatically created pull request(s) to ensure the cherry-pick was successful and the changes are correct. Once approved, merge the pull request.
|
||||||
|
|||||||
Reference in New Issue
Block a user