Skip to content

Commit

Permalink
Add some env var aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Sep 21, 2020
1 parent 385accf commit cbe0c9f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,22 @@

<!-- Your comment below this -->

# 10.3.2

- Improved `tsconfig.json` file lookup strategy: it now looks for it starting from the location of the danger file.
#1068 [@igorbek](https://github.com/igorbek)

- Adds aliases to the FakeCI env vars. You could now have something like:
```yml
- run: "npx danger-ts ci"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DANGER_MANUAL_CI: true
DANGER_MANUAL_GH_REPO: ${{ steps.pr_info.outputs.repo }}
DANGER_MANUAL_PR: ${{ steps.pr_info.outputs.number }}
```
Which looks more intentional instead of: `DANGER_FAKE_CI` etc. [@orta](https://github.com/orta)

<!-- Your comment above this -->

# 10.3.1
Expand Down
10 changes: 7 additions & 3 deletions source/ci_source/providers/Fake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export class FakeCI implements CISource {

constructor(env: Env) {
const defaults = {
repo: env.DANGER_TEST_REPO || "artsy/emission", // TODO: default to empty string ?
pr: env.DANGER_TEST_PR || "327", // TODO: default to empty string ?
repo: env.DANGER_TEST_REPO || env.DANGER_MANUAL_GH_REPO || "artsy/emission", // TODO: default to empty string ?
pr: env.DANGER_TEST_PR || env.DANGER_MANUAL_PR_NUM || "327", // TODO: default to empty string ?
}

this.env = { ...env, ...defaults }
Expand All @@ -17,7 +17,11 @@ export class FakeCI implements CISource {
}

get isCI(): boolean {
return ensureEnvKeysExist(this.env, ["DANGER_FAKE_CI"]) || ensureEnvKeysExist(this.env, ["DANGER_LOCAL_NO_CI"])
return (
ensureEnvKeysExist(this.env, ["DANGER_FAKE_CI"]) ||
ensureEnvKeysExist(this.env, ["DANGER_LOCAL_NO_CI"]) ||
ensureEnvKeysExist(this.env, ["DANGER_MANUAL_CI"])
)
}

get isPR(): boolean {
Expand Down
4 changes: 2 additions & 2 deletions source/platforms/github/GitHubAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ export class GitHubAPI {

const useGitHubActionsID = process.env["GITHUB_WORKFLOW"] && !process.env["DANGER_GITHUB_API_TOKEN"]
if (useGitHubActionsID) {
// This is the user.id of the github-actions app(https://github.com/apps/github-actions)
// that is used to comment when using danger in Github Action
// This is the user.id of the github-actions app (https://github.com/apps/github-actions)
// that is used to comment when using danger in a GitHub Action
// with GITHUB_TOKEN (https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token)
return 41898282
}
Expand Down
5 changes: 4 additions & 1 deletion source/platforms/github/GitHubUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ export const createOrAddLabel = (pr: GitHubPRDSL | undefined, api: GitHub) => as
d("Checking for existing labels")
let label: any = null
try {
const existingLabels = await api.paginate('GET /repos/:owner/:repo/labels', { owner: config.owner, repo: config.repo })
const existingLabels = await api.paginate("GET /repos/:owner/:repo/labels", {
owner: config.owner,
repo: config.repo,
})
label = existingLabels.find((l: any) => l.name == labelConfig.name)
} catch (e) {
d("api.issues.getLabels gave an error", e)
Expand Down

0 comments on commit cbe0c9f

Please sign in to comment.