diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 915827e..94ec4c6 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -267,6 +267,24 @@ describe('action', () => { expect(setOutputMock).toHaveBeenNthCalledWith(2, 'category', 'extra small') }) + it('runs the workflow sucessfully regardless of casing of optIns and pull request author login', async () => { + // Mock the @actions/github context. + Object.defineProperty(github, 'context', { + value: pullRequestEventContext({ user: { login: 'LeReBeAr' } }) + }) + + loadConfigurationMock.mockImplementation(() => ({ + optIns: ['lerebear'] + })) + + await main.run() + + expect(runMock).toHaveReturned() + expect(setFailedMock).not.toHaveBeenCalled() + expect(setOutputMock).toHaveBeenNthCalledWith(1, 'score', 1) + expect(setOutputMock).toHaveBeenNthCalledWith(2, 'category', 'extra small') + }) + it('skips the workflow entirely when the pull request author has not opted into it', async () => { // Mock the @actions/github context. Object.defineProperty(github, 'context', { diff --git a/dist/index.js b/dist/index.js index 0397a15..d699a30 100644 --- a/dist/index.js +++ b/dist/index.js @@ -105840,7 +105840,7 @@ var OptInStatus; function getOptInStatus(pull, config) { const usersWhoHaveOptedin = config.optIns || []; const userHasOptedOut = usersWhoHaveOptedin.length && - !usersWhoHaveOptedin.find((login) => login === pull.user.login); + !usersWhoHaveOptedin.find((login) => login.toLowerCase() === pull.user.login.toLowerCase()); if (userHasOptedOut && config.shadowOptOuts) { core.info('Executing workflow silently for user who was not opted in'); return OptInStatus.Shadow; diff --git a/src/initializer.ts b/src/initializer.ts index 9a751e9..fa3ea4d 100644 --- a/src/initializer.ts +++ b/src/initializer.ts @@ -43,7 +43,9 @@ export function getOptInStatus( const usersWhoHaveOptedin = config.optIns || [] const userHasOptedOut = usersWhoHaveOptedin.length && - !usersWhoHaveOptedin.find((login: string) => login === pull.user.login) + !usersWhoHaveOptedin.find( + (login: string) => login.toLowerCase() === pull.user.login.toLowerCase() + ) if (userHasOptedOut && config.shadowOptOuts) { core.info('Executing workflow silently for user who was not opted in')