Skip to content

Commit 2d309a2

Browse files
authored
✨ Added support for fine grained tokens (#268)
1 parent 3e67723 commit 2d309a2

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ inputs:
1515
description: |
1616
The path for the sync configuration file
1717
required: false
18+
IS_FINE_GRAINED:
19+
description: |
20+
Label GH_PAT as a fine grained token
21+
required: false
1822
PR_LABELS:
1923
description: |
2024
Labels which will be added to the pull request. Defaults to sync. Set to false to turn off

dist/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29830,6 +29830,10 @@ try {
2983029830
key: 'CONFIG_PATH',
2983129831
default: '.github/sync.yml'
2983229832
}),
29833+
IS_FINE_GRAINED: getInput({
29834+
key: 'IS_FINE_GRAINED',
29835+
default: false
29836+
}),
2983329837
COMMIT_BODY: getInput({
2983429838
key: 'COMMIT_BODY',
2983529839
default: ''
@@ -30053,6 +30057,7 @@ const fs = __nccwpck_require__(7147)
3005330057
const {
3005430058
GITHUB_TOKEN,
3005530059
IS_INSTALLATION_TOKEN,
30060+
IS_FINE_GRAINED,
3005630061
GIT_USERNAME,
3005730062
GIT_EMAIL,
3005830063
TMP_DIR,
@@ -30100,7 +30105,7 @@ class Git {
3010030105
// Set values to current repo
3010130106
this.repo = repo
3010230107
this.workingDir = path.join(TMP_DIR, repo.uniqueName)
30103-
this.gitUrl = `https://${ IS_INSTALLATION_TOKEN ? 'x-access-token:' : '' }${ GITHUB_TOKEN }@${ repo.fullName }.git`
30108+
this.gitUrl = `https://${ IS_INSTALLATION_TOKEN ? 'x-access-token:' : '' }${ IS_FINE_GRAINED ? 'oauth:' : '' }${ GITHUB_TOKEN }@${ repo.fullName }.git`
3010430109

3010530110
await this.clone()
3010630111
await this.setIdentity()

src/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ try {
4141
key: 'CONFIG_PATH',
4242
default: '.github/sync.yml'
4343
}),
44+
IS_FINE_GRAINED: getInput({
45+
key: 'IS_FINE_GRAINED',
46+
default: false
47+
}),
4448
COMMIT_BODY: getInput({
4549
key: 'COMMIT_BODY',
4650
default: ''

src/git.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const fs = require('fs')
99
const {
1010
GITHUB_TOKEN,
1111
IS_INSTALLATION_TOKEN,
12+
IS_FINE_GRAINED,
1213
GIT_USERNAME,
1314
GIT_EMAIL,
1415
TMP_DIR,
@@ -56,7 +57,7 @@ class Git {
5657
// Set values to current repo
5758
this.repo = repo
5859
this.workingDir = path.join(TMP_DIR, repo.uniqueName)
59-
this.gitUrl = `https://${ IS_INSTALLATION_TOKEN ? 'x-access-token:' : '' }${ GITHUB_TOKEN }@${ repo.fullName }.git`
60+
this.gitUrl = `https://${ IS_INSTALLATION_TOKEN ? 'x-access-token:' : '' }${ IS_FINE_GRAINED ? 'oauth:' : '' }${ GITHUB_TOKEN }@${ repo.fullName }.git`
6061

6162
await this.clone()
6263
await this.setIdentity()

0 commit comments

Comments
 (0)