Skip to content

Commit faa3d5d

Browse files
authored
Merge pull request #1439 from danger/logs_not_pr
Logs when its not the PR run on GH workflows
2 parents 05705c1 + 686f401 commit faa3d5d

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
## Main
1616

1717
<!-- Your comment below this -->
18+
19+
- Adds a log when you run on GitHub Actions without being a pull_request - [@orta]
20+
1821
<!-- Your comment above this -->
1922

2023

source/ci_source/providers/GitHubActions.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,14 @@ export class GitHubActions implements CISource {
271271
// return process.env.BUILD_URL
272272
// }
273273
}
274+
275+
export const githubActionsWorkflowWarningCheck = () => {
276+
const eventName = process.env.GITHUB_EVENT_NAME
277+
const isPR = eventName === "pull_request"
278+
if (!isPR) {
279+
console.log(
280+
"Note: Running Danger on with generalised GitHub Actions support, this does not include `danger.github.pr`."
281+
)
282+
console.log(" If you expected a PR run, change your workflow's 'on' to be pull_request.")
283+
}
284+
}

source/commands/ci/runner.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import dangerRunToRunnerCLI from "../utils/dangerRunToRunnerCLI"
1313
import { CISource } from "../../ci_source/ci_source"
1414
import { readFileSync } from "fs"
1515
import { join } from "path"
16+
import { githubActionsWorkflowWarningCheck } from "../../ci_source/providers/GitHubActions"
1617

1718
const d = debug("process_runner")
1819

@@ -33,6 +34,7 @@ export const runRunner = async (app: SharedCLI, config?: Partial<RunnerConfig>)
3334

3435
const configSource = config && config.source
3536
const source = configSource || (await getRuntimeCISource(app))
37+
d(`Got a CI: ${source?.name}`)
3638

3739
// This does not set a failing exit code, because it's also likely
3840
// danger is running on a CI run on the merge of a PR, and not just
@@ -42,6 +44,11 @@ export const runRunner = async (app: SharedCLI, config?: Partial<RunnerConfig>)
4244
console.log("Skipping Danger due to this run not executing on a PR.")
4345
}
4446

47+
// Extra logging for GitHub Actions
48+
if (source && source.isPR && source.name === "GitHub Actions") {
49+
githubActionsWorkflowWarningCheck()
50+
}
51+
4552
// The optimal path when on a PR
4653
if (source && source.isPR) {
4754
const configPlatform = config && config.platform

source/commands/init/add-to-ci.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const githubActions = async (ui: InitUI, state: InitState) => {
77
ui.say("So, you don't need to create a bot account.")
88
ui.pause(0.5)
99

10-
ui.say("You will want to add a new step in an existing workflow yaml file.")
10+
ui.say("You will want to add a new step in an existing workflow yaml file which uses `on: pull_request`.")
1111
ui.pause(0.2)
1212

1313
ui.say("The step should look like this:")
@@ -38,7 +38,7 @@ export const githubActions = async (ui: InitUI, state: InitState) => {
3838
ui.say("This would make Danger very spammy on a Pull Request.")
3939

4040
ui.pause(0.1)
41-
ui.say("To get started, add a new step in an existing workflow file.")
41+
ui.say("To get started, add a new step in an existing workflow file which uses `on: pull_request`.")
4242
ui.say("The step should look like this:")
4343
ui.say("")
4444
ui.say("```yaml")

0 commit comments

Comments
 (0)