Skip to content

Commit

Permalink
fix: move owner/repo to top level index.js to avoid issues with context
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickHeneise committed Sep 22, 2022
1 parent 41d8b48 commit abc6660
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26083,9 +26083,8 @@ var __webpack_exports__ = {}
}
} // CONCATENATED MODULE: ./src/lib/gh-query.js

async function query(octokit, context, core) {
async function query(octokit, owner, repo, core) {
core.info('Querying for reactions')
const [owner, repo] = context.actor.split('/')

const query = `
query reactions($owner: String!, $repo: String!, $size: Int!) {
Expand Down Expand Up @@ -26196,13 +26195,14 @@ var __webpack_exports__ = {}
context.botUser = botUser

const owner = process.env.GITHUB_REPOSITORY_OWNER
const repo = process.env.GITHUB_REPOSITORY_NAME
if (context.eventName === 'workflow_dispatch') {
const users = await query(octokit, context, core)
const users = await query(octokit, owner, repo, core)
for (const user of users) {
await gh_invite(octokit, owner, user, core)
}
} else if (context.eventName === 'schedule') {
const users = await query(octokit, context, core)
const users = await query(octokit, owner, repo, core)
for (const user of users) {
await gh_invite(octokit, owner, user, core)
}
Expand Down
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ async function run() {
context.botUser = botUser

const owner = process.env.GITHUB_REPOSITORY_OWNER
const repo = process.env.GITHUB_REPOSITORY_NAME
if (context.eventName === 'workflow_dispatch') {
const users = await query(octokit, context, core)
const users = await query(octokit, owner, repo, core)
for (const user of users) {
await invite(octokit, owner, user, core)
}
} else if (context.eventName === 'schedule') {
const users = await query(octokit, context, core)
const users = await query(octokit, owner, repo, core)
for (const user of users) {
await invite(octokit, owner, user, core)
}
Expand Down
3 changes: 1 addition & 2 deletions src/lib/gh-query.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export default async function query(octokit, context, core) {
export default async function query(octokit, owner, repo, core) {
core.info('Querying for reactions')
const [owner, repo] = context.actor.split('/')

const query = `
query reactions($owner: String!, $repo: String!, $size: Int!) {
Expand Down
3 changes: 2 additions & 1 deletion test/query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ tap.test('query() should return a list of users', async (t) => {
return Promise.resolve(emptyResult)
}
},
{ actor: 'hello/world' },
'hello',
'world',
core
)
t.same(actual, [])
Expand Down

0 comments on commit abc6660

Please sign in to comment.