Skip to content

Commit

Permalink
Merge pull request #107 from contributor-assistant/error-handling-for…
Browse files Browse the repository at this point in the history
…k-fix

Bug fix: Fail gracefully when Pr is created from fork
  • Loading branch information
ibakshay authored Jul 20, 2022
2 parents adf5016 + 60a7215 commit 58b464b
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 7 deletions.
143 changes: 143 additions & 0 deletions .idea/workspace.xml

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

2 changes: 1 addition & 1 deletion lib/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { context } from '@actions/github'
import { setupClaCheck } from './setupClaCheck'
import { lockPullRequest } from './pullrequest/pullRequestLock'
import { octokit } from './octokit'

import * as core from '@actions/core'
import * as input from './shared/getInputs'
Expand Down
7 changes: 3 additions & 4 deletions src/octokit.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { getOctokit } from '@actions/github'

const githubActionsDefaultToken = process.env.GITHUB_TOKEN
const personalAcessToken = process.env.PERSONAL_ACCESS_TOKEN as string
const personalAccessToken = process.env.PERSONAL_ACCESS_TOKEN as string

export const octokit = getOctokit(githubActionsDefaultToken as string)
export const octokitUsingPAT = isPersonalAccessTokenPresent() ? getOctokit(personalAcessToken as string) : octokit
export const octokitUsingPAT = isPersonalAccessTokenPresent() ? getOctokit(personalAccessToken as string) : octokit

export function isPersonalAccessTokenPresent(): boolean {

return (typeof personalAcessToken !== "undefined")
return personalAccessToken !== ""
}

4 changes: 2 additions & 2 deletions src/setupClaCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function setupClaCheck() {

let committerMap = getInitialCommittersMap()
if (!isPersonalAccessTokenPresent()) {
core.setFailed('Please enter a personal access token as a environment variable in the CLA workflow file as described in the https://github.com/cla-assistant/github-action documentation')
core.setFailed('Please enter a personal access token as a environment variable in the CLA workflow file as described in the https://github.com/contributor-assistant/github-action documentation')
return
}

Expand Down Expand Up @@ -104,4 +104,4 @@ const getInitialCommittersMap = (): CommitterMap => ({
signed: [],
notSigned: [],
unknown: []
})
})

0 comments on commit 58b464b

Please sign in to comment.