From edfe3495a113ee3d560a380490e5490d9252c6ef Mon Sep 17 00:00:00 2001 From: Quang Minh Pho <87009633+qminhpho@users.noreply.github.com> Date: Tue, 1 Feb 2022 13:56:30 +0100 Subject: [PATCH] Feature/adapt for ghes endpoint (#12) --- README.md | 9 +++++++++ dist/main.js | 3 ++- main.ts | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 84b1e2f..d1a3c0c 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,15 @@ Sometimes you want to tag a team or multiple persons when an issue (or something # Usage: +Requirements: + +A GitHub App [https://docs.github.com/en/developers/apps/getting-started-with-apps/about-apps#about-github-apps] installed on the repository/organization that the GitHub Actions Workflow will execute from +The GitHub Apps minimally should have the following permissions: + - Read & write access to Issues + - Read-only access to Members + - Read-only access to Administration (Only applicable for GitHub Enterprise Server) +A method to retrieve `GITHUB_TOKEN` (script/action), a good example for action would be `peter-murray/workflow-application-token-action` + ``` yaml - uses: devops-actions/issue-comment-tag@v0.1.0 with: diff --git a/dist/main.js b/dist/main.js index ab7dd4a..11c275d 100644 --- a/dist/main.js +++ b/dist/main.js @@ -14667,6 +14667,7 @@ function run() { const team = core.getInput("team") || process.env.team || ""; let repo = core.getInput("repo") || process.env.repo || ""; let owner = core.getInput("owner") || process.env.owner || ""; + let BASE_URL = process.env.GITHUB_API_URL || "https://api.github.com"; if (!PAT || PAT === "") { core.setFailed("Cannot load 'GITHUB_TOKEN' which is required to be able to post the issue"); return; @@ -14686,7 +14687,7 @@ function run() { console.log(`Converted owner/repo input for the repo to owner: [${owner}] and repo: [${repo}]`); } console.log(`Parameters that we have. Owner: [${owner}], Repo: [${repo}], Issue: [${issue}], team: [${team}] and a token with length: [${PAT.length}]`); - const octokit = new import_octokit.Octokit({ auth: PAT }); + const octokit = new import_octokit.Octokit({ auth: PAT, baseUrl: BASE_URL }); try { console.log(`Getting the list of actions from the issue: [${issue}]`); const { data: currentIssue } = yield octokit.rest.issues.get({ diff --git a/main.ts b/main.ts index 27c23ea..6894738 100644 --- a/main.ts +++ b/main.ts @@ -13,6 +13,8 @@ async function run(): Promise { const team = core.getInput('team') || process.env.team || '' let repo = core.getInput('repo') || process.env.repo || '' let owner = core.getInput('owner') || process.env.owner || '' + //Retrieve GitHub endpoint so that Octokit can communicate to the correct GitHub instance instead of the default public "api.github.com" + let BASE_URL = process.env.GITHUB_API_URL || "https://api.github.com" if (!PAT || PAT === '') { core.setFailed( @@ -44,7 +46,7 @@ async function run(): Promise { } console.log(`Parameters that we have. Owner: [${owner}], Repo: [${repo}], Issue: [${issue}], team: [${team}] and a token with length: [${PAT.length}]`) - const octokit = new Octokit({auth: PAT}) + const octokit = new Octokit({auth: PAT, baseUrl: BASE_URL}) // todo: check if the team / user to tag exists at all try {