Skip to content

Commit

Permalink
✨ Added support for fine grained tokens (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
AidanFogarty committed Nov 30, 2022
1 parent 3e67723 commit 2d309a2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ inputs:
description: |
The path for the sync configuration file
required: false
IS_FINE_GRAINED:
description: |
Label GH_PAT as a fine grained token
required: false
PR_LABELS:
description: |
Labels which will be added to the pull request. Defaults to sync. Set to false to turn off
Expand Down
7 changes: 6 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29830,6 +29830,10 @@ try {
key: 'CONFIG_PATH',
default: '.github/sync.yml'
}),
IS_FINE_GRAINED: getInput({
key: 'IS_FINE_GRAINED',
default: false
}),
COMMIT_BODY: getInput({
key: 'COMMIT_BODY',
default: ''
Expand Down Expand Up @@ -30053,6 +30057,7 @@ const fs = __nccwpck_require__(7147)
const {
GITHUB_TOKEN,
IS_INSTALLATION_TOKEN,
IS_FINE_GRAINED,
GIT_USERNAME,
GIT_EMAIL,
TMP_DIR,
Expand Down Expand Up @@ -30100,7 +30105,7 @@ class Git {
// Set values to current repo
this.repo = repo
this.workingDir = path.join(TMP_DIR, repo.uniqueName)
this.gitUrl = `https://${ IS_INSTALLATION_TOKEN ? 'x-access-token:' : '' }${ GITHUB_TOKEN }@${ repo.fullName }.git`
this.gitUrl = `https://${ IS_INSTALLATION_TOKEN ? 'x-access-token:' : '' }${ IS_FINE_GRAINED ? 'oauth:' : '' }${ GITHUB_TOKEN }@${ repo.fullName }.git`

await this.clone()
await this.setIdentity()
Expand Down
4 changes: 4 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ try {
key: 'CONFIG_PATH',
default: '.github/sync.yml'
}),
IS_FINE_GRAINED: getInput({
key: 'IS_FINE_GRAINED',
default: false
}),
COMMIT_BODY: getInput({
key: 'COMMIT_BODY',
default: ''
Expand Down
3 changes: 2 additions & 1 deletion src/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const fs = require('fs')
const {
GITHUB_TOKEN,
IS_INSTALLATION_TOKEN,
IS_FINE_GRAINED,
GIT_USERNAME,
GIT_EMAIL,
TMP_DIR,
Expand Down Expand Up @@ -56,7 +57,7 @@ class Git {
// Set values to current repo
this.repo = repo
this.workingDir = path.join(TMP_DIR, repo.uniqueName)
this.gitUrl = `https://${ IS_INSTALLATION_TOKEN ? 'x-access-token:' : '' }${ GITHUB_TOKEN }@${ repo.fullName }.git`
this.gitUrl = `https://${ IS_INSTALLATION_TOKEN ? 'x-access-token:' : '' }${ IS_FINE_GRAINED ? 'oauth:' : '' }${ GITHUB_TOKEN }@${ repo.fullName }.git`

await this.clone()
await this.setIdentity()
Expand Down

0 comments on commit 2d309a2

Please sign in to comment.