Skip to content

Commit c5269c4

Browse files
authored
permissiong for nightly job (#8652)
1 parent 89444fb commit c5269c4

4 files changed

Lines changed: 87 additions & 16 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 'Create and Merge Pull Request'
2+
description: 'Creates a pull request and merges it automatically.'
3+
4+
inputs:
5+
branch-name:
6+
description: 'The name of the branch to create the PR from.'
7+
required: true
8+
pr-title:
9+
description: 'The title of the pull request.'
10+
required: true
11+
pr-body:
12+
description: 'The body of the pull request.'
13+
required: true
14+
base-branch:
15+
description: 'The branch to merge into.'
16+
required: true
17+
default: 'main'
18+
app-id:
19+
description: 'The ID of the GitHub App.'
20+
required: true
21+
private-key:
22+
description: 'The private key of the GitHub App.'
23+
required: true
24+
dry-run:
25+
description: 'Whether to run in dry-run mode.'
26+
required: false
27+
default: 'false'
28+
29+
runs:
30+
using: 'composite'
31+
steps:
32+
- name: 'Generate GitHub App Token'
33+
id: 'generate_token'
34+
if: "inputs.dry-run == 'false'"
35+
uses: 'actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b'
36+
with:
37+
app-id: '${{ inputs.app-id }}'
38+
private-key: '${{ inputs.private-key }}'
39+
permission-pull-requests: 'write'
40+
permission-contents: 'write'
41+
42+
- name: 'Create and Approve Pull Request'
43+
if: "inputs.dry-run == 'false'"
44+
env:
45+
GH_TOKEN: '${{ steps.generate_token.outputs.token }}'
46+
shell: 'bash'
47+
run: |
48+
gh pr create \
49+
--title "${{ inputs.pr-title }}" \
50+
--body "${{ inputs.pr-body }}" \
51+
--base "${{ inputs.base-branch }}" \
52+
--head "${{ inputs.branch-name }}" \
53+
--fill
54+
gh pr merge --auto --squash

.github/workflows/create-patch-pr.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,22 @@ jobs:
4646
git config user.name "gemini-cli-robot"
4747
git config user.email "gemini-cli-robot@google.com"
4848
49+
- name: 'Generate GitHub App Token'
50+
id: 'generate_token'
51+
uses: 'actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b'
52+
with:
53+
app-id: '${{ secrets.APP_ID }}'
54+
private-key: '${{ secrets.PRIVATE_KEY }}'
55+
permission-pull-requests: 'write'
56+
permission-contents: 'write'
57+
4958
- name: 'Create Patch for Stable'
5059
if: "github.event.inputs.channel == 'stable'"
5160
env:
52-
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
61+
GH_TOKEN: '${{ steps.generate_token.outputs.token }}'
5362
run: 'node scripts/create-patch-pr.js --commit=${{ github.event.inputs.commit }} --channel=stable --dry-run=${{ github.event.inputs.dry_run }}'
5463

5564
- name: 'Create Patch for Preview'
5665
env:
57-
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
66+
GH_TOKEN: '${{ steps.generate_token.outputs.token }}'
5867
run: 'node scripts/create-patch-pr.js --commit=${{ github.event.inputs.commit }} --channel=${{ github.event.inputs.channel }} --dry-run=${{ github.event.inputs.dry_run }}'

.github/workflows/nightly-release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ jobs:
2525
release:
2626
runs-on: 'ubuntu-latest'
2727
permissions:
28+
contents: 'write'
29+
packages: 'write'
2830
issues: 'write'
31+
pull-requests: 'write'
2932
steps:
3033
- name: 'Checkout'
3134
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8'
@@ -71,6 +74,16 @@ jobs:
7174
dry-run: '${{ github.event.inputs.dry_run }}'
7275
previous-tag: '${{ steps.nightly_version.outputs.PREVIOUS_TAG }}'
7376

77+
- name: 'Create and Merge Pull Request'
78+
uses: './.github/actions/create-pull-request'
79+
with:
80+
branch-name: 'release/${{ steps.nightly_version.outputs.RELEASE_TAG }}'
81+
pr-title: 'chore(release): bump version to ${{ steps.nightly_version.outputs.RELEASE_VERSION }}'
82+
pr-body: 'Automated version bump for nightly release.'
83+
app-id: '${{ secrets.APP_ID }}'
84+
private-key: '${{ secrets.PRIVATE_KEY }}'
85+
dry-run: '${{ github.event.inputs.dry_run }}'
86+
7487
- name: 'Create Issue on Failure'
7588
if: '${{ failure() && github.event.inputs.dry_run == false }}'
7689
env:

.github/workflows/promote-release.yml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -317,20 +317,15 @@ jobs:
317317
echo "Dry run enabled. Skipping push."
318318
fi
319319
320-
- name: 'Create and Approve Pull Request'
321-
if: |-
322-
${{ github.event.inputs.dry_run == 'false' }}
323-
env:
324-
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
325-
BRANCH_NAME: '${{ steps.release_branch.outputs.BRANCH_NAME }}'
326-
run: |
327-
gh pr create \
328-
--title "chore(release): bump version to ${{ needs.calculate-versions.outputs.NEXT_NIGHTLY_VERSION }}" \
329-
--body "Automated version bump to prepare for the next nightly release." \
330-
--base "main" \
331-
--head "${BRANCH_NAME}" \
332-
--fill
333-
gh pr merge --auto --squash
320+
- name: 'Create and Merge Pull Request'
321+
uses: './.github/actions/create-pull-request'
322+
with:
323+
branch-name: '${{ steps.release_branch.outputs.BRANCH_NAME }}'
324+
pr-title: 'chore(release): bump version to ${{ needs.calculate-versions.outputs.NEXT_NIGHTLY_VERSION }}'
325+
pr-body: 'Automated version bump to prepare for the next nightly release.'
326+
app-id: '${{ secrets.APP_ID }}'
327+
private-key: '${{ secrets.PRIVATE_KEY }}'
328+
dry-run: '${{ github.event.inputs.dry_run }}'
334329

335330
- name: 'Create Issue on Failure'
336331
if: '${{ failure() && github.event.inputs.dry_run == false }}'

0 commit comments

Comments
 (0)