Skip to content

Commit 2c07e00

Browse files
authored
Merge pull request #39 from KingBain/patch-1
Change the ReadMe to use Github App generated Tokens
2 parents 3576c22 + 6312399 commit 2c07e00

File tree

1 file changed

+64
-3
lines changed

1 file changed

+64
-3
lines changed

README.md

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ The [personal access token](https://github.com/settings/tokens/).
3434

3535
Need to note, you can't use `GITHUB_TOKEN` because of [this limitation](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token)
3636

37+
Alternatively, you can use a **GitHub App token** for better security and flexibility. See the "GitHub App Token Setup" section below.
38+
3739
### `base`
3840

3941
**Required**
@@ -90,12 +92,12 @@ This github action doesn't set any default parameters.
9092

9193
**Optional**
9294

93-
Check if having auto-merge enabled in the PR is required, in order for the PR to
94-
be considered. It defaults to `true`, but if set to `false`, all PRs are
95-
considered for update (not just those with auto-merge enabled).
95+
Check if having auto-merge enabled in the PR is required, in order for the PR to be considered. It defaults to `true`, but if set to `false`, all PRs are considered for update (not just those with auto-merge enabled).
9696

9797
## Example usage
9898

99+
### Using Personal Access Token
100+
99101
```yml
100102
name: PR update
101103

@@ -122,6 +124,64 @@ jobs:
122124
123125
Replace the `VERSION_YOU_WANT_TO_USE` with the actual version you want to use, check the version format [here](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsuses)
124126

127+
### Using GitHub App Token
128+
129+
To improve security and flexibility, you can use a GitHub App token instead of a personal access token.
130+
131+
#### Steps to Set Up the GitHub App
132+
133+
1. **Create a GitHub App**:
134+
- Go to your GitHub Organization settings and create a new GitHub App.
135+
2. **Generate a Private Key**:
136+
- Once the app is created, generate a private key for authentication.
137+
3. **Assign Permissions**:
138+
- Grant the following permissions:
139+
- **Metadata**: Read access
140+
- **Content**: Read and write access
141+
- **Pull Requests**: Read and write access
142+
4. **Install the App**:
143+
- Install the app on all repositories or specific repositories where this action will run.
144+
5. **Save Variables and Secrets**:
145+
- Save the App ID as a repository or organization variable.
146+
- Save the private key as a repository or organization secret.
147+
148+
__If you have branch protection rules, ensure the GitHub App has an exemption to bypass those rules.__
149+
150+
#### Example Usage with GitHub App Token
151+
152+
```yml
153+
name: PR update
154+
155+
on:
156+
push:
157+
branches:
158+
- 'master'
159+
jobs:
160+
autoupdate:
161+
runs-on: ubuntu-latest
162+
steps:
163+
- name: Create App token
164+
id: create_token
165+
uses: actions/create-github-app-token@v1
166+
with:
167+
app-id: ${{ vars.GITHUB_APP_ID }}
168+
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
169+
170+
- name: Automatically update PR
171+
uses: adRise/update-pr-branch@VERSION_YOU_WANT_TO_USE
172+
with:
173+
token: ${{ steps.create_token.outputs.token }}
174+
base: 'master'
175+
required_approval_count: 2
176+
require_passed_checks: true
177+
allow_ongoing_checks: true
178+
sort: 'created'
179+
direction: 'desc'
180+
require_auto_merge_enabled: true
181+
```
182+
183+
---
184+
125185
## Development
126186

127187
```bash
@@ -131,3 +191,4 @@ yarn build
131191
```
132192

133193
Note: You need to run `yarn build` before commit the changes because when the action only use the compiled `dest/index.js`.
194+

0 commit comments

Comments
 (0)