From 2d309a25fa13173158743b3843a6d5e65cb41b1b Mon Sep 17 00:00:00 2001 From: Aidan Fogarty Date: Wed, 30 Nov 2022 09:40:34 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Added=20support=20for=20fine=20grai?= =?UTF-8?q?ned=20tokens=20(#268)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 4 ++++ dist/index.js | 7 ++++++- src/config.js | 4 ++++ src/git.js | 3 ++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index b889ce4c..3062779e 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/dist/index.js b/dist/index.js index 28f44f50..6d9cc5a1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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: '' @@ -30053,6 +30057,7 @@ const fs = __nccwpck_require__(7147) const { GITHUB_TOKEN, IS_INSTALLATION_TOKEN, + IS_FINE_GRAINED, GIT_USERNAME, GIT_EMAIL, TMP_DIR, @@ -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() diff --git a/src/config.js b/src/config.js index e9067083..e2d8f03c 100644 --- a/src/config.js +++ b/src/config.js @@ -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: '' diff --git a/src/git.js b/src/git.js index 695ef97e..50b81849 100644 --- a/src/git.js +++ b/src/git.js @@ -9,6 +9,7 @@ const fs = require('fs') const { GITHUB_TOKEN, IS_INSTALLATION_TOKEN, + IS_FINE_GRAINED, GIT_USERNAME, GIT_EMAIL, TMP_DIR, @@ -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()