Skip to content

Commit

Permalink
Feature/adapt for ghes endpoint (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Quang Minh Pho authored Feb 1, 2022
1 parent b46e6d5 commit edfe349
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
Expand Down
3 changes: 2 additions & 1 deletion dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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({
Expand Down
4 changes: 3 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ async function run(): Promise<void> {
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(
Expand Down Expand Up @@ -44,7 +46,7 @@ async function run(): Promise<void> {
}

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 {
Expand Down

0 comments on commit edfe349

Please sign in to comment.