From 67c115c9dfdf6677d4d1bbb52e5ea058e2924aa6 Mon Sep 17 00:00:00 2001 From: fogara23 Date: Wed, 9 Nov 2022 16:25:18 +0000 Subject: [PATCH] added support for fine grained tokens --- 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 f0bdc734..224ea29e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -21277,6 +21277,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: '' @@ -21506,6 +21510,7 @@ const fs = __nccwpck_require__(7147) const { GITHUB_TOKEN, IS_INSTALLATION_TOKEN, + IS_FINE_GRAINED, GIT_USERNAME, GIT_EMAIL, TMP_DIR, @@ -21553,7 +21558,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 56c17fff..f05d978b 100644 --- a/src/config.js +++ b/src/config.js @@ -40,6 +40,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 1ef550ac..8cae19b2 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()