Skip to content

Commit

Permalink
Merge pull request #7 from tspascoal/fixes/crash-when-org-not-passed
Browse files Browse the repository at this point in the history
[bug fix] If organization isn't passed owner wasn't being correctly reference
  • Loading branch information
tspascoal authored Feb 5, 2022
2 parents 45eb346 + 1257f89 commit f743525
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 91 deletions.
8 changes: 7 additions & 1 deletion dist/index.js

Large diffs are not rendered by default.

178 changes: 101 additions & 77 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "get-user-teams-membership",
"version": "1.0.0",
"version": "1.0.1",
"description": "GitHub Action to get a list a user teams membership",
"main": "dist/index.js",
"scripts": {
Expand All @@ -15,10 +15,10 @@
"url": "https://github.com/tspascoal/get-user-teams-membership"
},
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0"
"@actions/core": "^1.6.0",
"@actions/github": "^5.0.0"
},
"devDependencies": {
"@vercel/ncc": "^0.24.0"
"@vercel/ncc": "^0.33.1"
}
}
18 changes: 9 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
const core = require('@actions/core')
const github = require('@actions/github')
import { getInput, setOutput, setFailed } from '@actions/core'
import { getOctokit, context } from '@actions/github'

run()

async function run() {

try {

const api = github.getOctokit(core.getInput("GITHUB_TOKEN", { required: true }), {})
const api = getOctokit(getInput("GITHUB_TOKEN", { required: true }), {})

const organization = core.getInput("organization") || context.repo.owner
const username = core.getInput("username")
const team = core.getInput("team")
const organization = getInput("organization") || context.repo.owner
const username = getInput("username")
const team = getInput("team")

console.log(`Getting teams for ${username} in org ${organization}. Will check if belongs to ${team}`)

Expand Down Expand Up @@ -58,11 +58,11 @@ async function run() {
return team.toLowerCase() === teamName.toLowerCase()
})

core.setOutput("teams", teams)
core.setOutput("isTeamMember", isTeamMember)
setOutput("teams", teams)
setOutput("isTeamMember", isTeamMember)

} catch (error) {
console.log(error)
core.setFailed(error.message)
setFailed(error.message)
}
}

0 comments on commit f743525

Please sign in to comment.