Skip to content

Commit

Permalink
Merge pull request #227 from github/handle-github-emu-usernames
Browse files Browse the repository at this point in the history
use new github emu check
  • Loading branch information
GrantBirki authored Dec 18, 2023
2 parents 67cd82f + 43bd02c commit 9e2d366
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 14 deletions.
22 changes: 22 additions & 0 deletions __tests__/functions/admin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ test('runs isAdmin checks and finds a valid admin via handle reference', async (
)
})

test('runs isAdmin checks and finds a valid handle that is a GitHub EMU', async () => {
process.env.INPUT_ADMINS = 'username_company'
const contextNoAdmin = {
actor: 'username_company'
}
expect(await isAdmin(contextNoAdmin)).toStrictEqual(true)
expect(debugMock).toHaveBeenCalledWith(
'username_company is an admin via handle reference'
)
})

test('runs isAdmin checks and does not find a valid admin due to a bad GitHub handle', async () => {
process.env.INPUT_ADMINS = 'mona%lisa-'
const contextNoAdmin = {
actor: 'mona%lisa-'
}
expect(await isAdmin(contextNoAdmin)).toStrictEqual(false)
expect(debugMock).toHaveBeenCalledWith(
'mona%lisa- is not a valid GitHub username... skipping admin check'
)
})

test('runs isAdmin checks and does not find a valid admin', async () => {
process.env.INPUT_ADMINS = 'monalisa'
const contextNoAdmin = {
Expand Down
12 changes: 6 additions & 6 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

124 changes: 123 additions & 1 deletion dist/licenses.txt

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

8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@actions/github": "^6.0.0",
"@octokit/plugin-retry": "^6.0.1",
"dedent-js": "^1.0.1",
"github-username-regex": "^1.0.0",
"github-username-regex-js": "^1.0.0",
"nunjucks": "^3.2.4",
"@octokit/rest": "^20.0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion src/functions/admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import githubUsernameRegex from 'github-username-regex'
import githubUsernameRegex from 'github-username-regex-js'
import {octokitRetry} from '@octokit/plugin-retry'
import {COLORS} from './colors'

Expand Down

0 comments on commit 9e2d366

Please sign in to comment.