Skip to content

Commit

Permalink
Merge pull request #952 from danger/fix_github_actions
Browse files Browse the repository at this point in the history
Fix github actions check
  • Loading branch information
orta committed Nov 5, 2019
2 parents 6bbe565 + 22ef49e commit 43af539
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
// Note: if this is your first PR, you'll need to add your URL to the footnotes
// see the bottom of this file. The list there is sorted, try to follow that.
x
-->

## Master

<!-- Your comment below this -->

- Fix github actions checks - [@f-meloni]

<!-- Your comment above this -->

# 9.2.3
Expand Down
6 changes: 3 additions & 3 deletions source/ci_source/providers/GitHubActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class GitHubActions implements CISource {
}

get useEventDSL() {
return this.event.pull_request !== undefined || this.event.issue !== undefined
return this.event.pull_request === undefined && this.event.issue === undefined
}

get pullRequestID(): string {
Expand All @@ -179,8 +179,8 @@ export class GitHubActions implements CISource {
get repoSlug(): string {
if (this.event.pull_request !== undefined) {
return this.event.pull_request.base.repo.full_name
} else if (this.event.repo !== undefined) {
return this.event.repo.full_name
} else if (this.event.repository !== undefined) {
return this.event.repository.full_name
}

throw new Error("repoSlug was called on GitHubActions when it wasn't a PR")
Expand Down
14 changes: 7 additions & 7 deletions source/ci_source/providers/_tests/_gitHubActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ const issueEvent = {
issue: {
number: "2",
},
repo: {
repository: {
full_name: "danger/danger-js",
},
}

describe("use event DSL", () => {
it("returns true when event.json contains pull_request data", () => {
it("returns false when event.json contains pull_request data", () => {
const ci = new GitHubActions({}, pullRequestEvent)
expect(ci.useEventDSL).toBeTruthy()
expect(ci.useEventDSL).toBeFalsy()
})

it("returns true when event.json contains issue data", () => {
it("returns false when event.json contains issue data", () => {
const ci = new GitHubActions({}, issueEvent)
expect(ci.useEventDSL).toBeTruthy()
expect(ci.useEventDSL).toBeFalsy()
})

it("returns false when event.json doesn't contain issue or pull_request data", () => {
it("returns true when event.json doesn't contain issue or pull_request data", () => {
const ci = new GitHubActions({}, {})
expect(ci.useEventDSL).toBeFalsy()
expect(ci.useEventDSL).toBeTruthy()
})
})

Expand Down
5 changes: 5 additions & 0 deletions source/platforms/github/GitHubAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ export class GitHubAPI {
return parseInt(perilID)
}

const useGitHubActionsID = process.env["GITHUB_WORKFLOW"]
if (useGitHubActionsID) {
return 41898282
}

const info = await this.getUserInfo()
return info.id
}
Expand Down

0 comments on commit 43af539

Please sign in to comment.