-
-
Notifications
You must be signed in to change notification settings - Fork 367
/
Bitrise.ts
76 lines (68 loc) · 2.15 KB
/
Bitrise.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { Env, CISource } from "../ci_source"
import { ensureEnvKeysExist, ensureEnvKeysAreInt } from "../ci_source_helpers"
/**
* ### CI Setup
* <!-- JS --!>
* You need to edit your `bitrise.yml` (in version control, or directly from UI) to include `yarn danger ci`.
*
* You can set `is_always_run: true` to ensure that it reports even if previous steps fails
*
* ```yaml
* workflows:
* <your_workflow_name>:
* steps:
* - yarn:
* inputs:
* - args: ci
* - command: danger
* is_always_run: true
* ```
*
* Adding this to your `bitrise.yml` allows Danger to fail your build, both on the Bitrise website and within your Pull Request.
* With that set up, you can edit your job to add `yarn danger ci` at the build action.
*
* <!-- !JS --!>
* <!-- Swift --!>
*
* No instructions yet, but basically:
*
* - Install Danger JS globally
* - Run `swift build`
* - Run `swift run danger-swift ci`
*
* <!-- !Swift --!>
*
* ### Token Setup
*
* You need to add the platform environment variables, to do this,
* go to your repo's secrets, which should look like: `https://www.bitrise.io/app/[app_id]#/workflow` and secrets tab.
*
* You should make sure to check the case "Expose for Pull Requests?".
*/
export class Bitrise implements CISource {
constructor(private readonly env: Env) {}
get name(): string {
return "Bitrise"
}
get isCI(): boolean {
return ensureEnvKeysExist(this.env, ["BITRISE_IO"])
}
get isPR(): boolean {
const mustHave = ["BITRISEIO_GIT_REPOSITORY_OWNER", "BITRISEIO_GIT_REPOSITORY_SLUG"]
const mustBeInts = ["BITRISE_PULL_REQUEST"]
return ensureEnvKeysExist(this.env, mustHave) && ensureEnvKeysAreInt(this.env, mustBeInts)
}
get pullRequestID(): string {
return this.env.BITRISE_PULL_REQUEST
}
get repoSlug(): string {
return `${this.env.BITRISEIO_GIT_REPOSITORY_OWNER}/${this.env.BITRISEIO_GIT_REPOSITORY_SLUG}`
}
get ciRunURL() {
return this.env.BITRISE_BUILD_URL
}
get commitHash() {
return this.env.BITRISE_GIT_COMMIT
}
}
// See https://devcenter.bitrise.io/builds/available-environment-variables/