forked from bitrise-io/bitrise-steplib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitrise.yml
197 lines (184 loc) · 5.47 KB
/
bitrise.yml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
format_version: 1.0.0
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
app:
envs:
- STEPLIB_SOURCE: 'https://github.com/bitrise-io/bitrise-steplib.git'
# define these ENVs in your .bitrise.secrets.yml
- AWS_ACCESS_KEY_ID:
- AWS_SECRET_ACCESS_KEY:
- S3_UPLOAD_BUCKET:
- S3_UPLOAD_BUCKET_REGION:
- IS_LOCAL_TEST:
- BITRISE_GIT_BRANCH:
- BITRISE_BUILD_URL:
- BITRISE_APP_TITLE:
- SLACK_WEBHOOK_URL:
- SLACK_CHANNEL:
trigger_map:
- pattern: generate/spec.json
workflow: _generate
workflows:
_notifications:
steps:
- slack:
inputs:
- webhook_url: "${SLACK_WEBHOOK_URL}"
- channel: "${SLACK_CHANNEL}"
- from_username: "${BITRISE_APP_TITLE} - OK"
- from_username_on_error: "${BITRISE_APP_TITLE} - ERROR"
- message: |-
Workflow: *${BITRISE_WORKFLOW_ID}*
Branch: ${BITRISE_GIT_BRANCH}
Build URL: ${BITRISE_BUILD_URL}
install_required_tool_versions:
steps:
- script:
title: Make sure the required Stepman version is installed
run_if: .IsCI
inputs:
- content: |-
#!/bin/bash
set -e
set -v
curl -fL https://github.com/bitrise-io/bitrise/releases/download/1.1.0/bitrise-$(uname -s)-$(uname -m) > /usr/local/bin/bitrise
chmod +x /usr/local/bin/bitrise
bitrise setup --minimal
# Stepman version:
stepman --version
_generate:
title: Workflow for testing, PR check
description: |-
Adds a clean copy of this StepLib collection to stepman,
calls a setup on it, moves the generated spec.json to
a specified path and makes the path available for other workflows.
steps:
- script:
title: Set TMP_COLLECTION_ID
inputs:
- content: |-
#!/bin/bash
set -e
set -v
envman add --key TMP_COLLECTION_ID --value "$(pwd)"
- script:
title: Remove previous version of this local spec from stepman
inputs:
- content: |-
#!/bin/bash
set -e
set -v
stepman delete -c "${TMP_COLLECTION_ID}"
- script:
title: Generate
inputs:
- content: |-
#!/bin/bash
set -e
set -v
tmp_dir="$(pwd)/_tmp"
mkdir -p "${tmp_dir}"
spec_path="${tmp_dir}/spec.json"
stepman setup --local -c "${TMP_COLLECTION_ID}" --copy-spec-json="${spec_path}"
envman add --key SPEC_JSON_PATH --value "${spec_path}"
- script:
title: tmp
inputs:
- content: |-
#!/bin/bash
set -e
echo "SPEC_JSON_PATH: ${SPEC_JSON_PATH}"
pr_audit:
title: Pull Request audit
description: |-
Performs an audit only on the changed step.yml files, and on the
related Steps.
envs:
- BITRISE_WORKFLOW_ID: pr_audit
before_run:
- _generate
after_run:
- _notifications
steps:
- script:
title: List of changed files
dependencies:
- manager: brew
name: go
inputs:
- content: |-
set -e
localtest_param=""
if [[ "${IS_LOCAL_TEST}" == "true" ]] ; then
localtest_param="--localtest"
fi
go run ./_scripts/audit/audit_changed_steps.go --collectionid "${TMP_COLLECTION_ID}" ${localtest_param}
full_audit:
title: Full Audit
description: |-
Performs a full audit on the collection.
before_run:
- _generate
steps:
- script:
title: Run full audit on the StepLib collection
inputs:
- content: |-
set -e
set -v
stepman audit --collection "${TMP_COLLECTION_ID}"
deploy:
title: Workflow for deployment
description: |-
Deploys the StepLib to Amazon S3
envs:
- AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
- S3_UPLOAD_BUCKET: $S3_UPLOAD_BUCKET
- BITRISE_WORKFLOW_ID: "DEPLOY"
before_run:
- install_required_tool_versions
- full_audit
after_run:
- _notifications
steps:
- script:
title: Check spec.json - exist?
inputs:
- content: |-
#!/bin/bash
set -e
if [ ! -f "${SPEC_JSON_PATH}" ] ; then
echo " [!] spec.json does not exist at path: ${SPEC_JSON_PATH}"
exit 1
fi
- script:
title: Fix steplib_source in spec.json
inputs:
- content: |-
require 'json'
spec_json_pth = ENV['SPEC_JSON_PATH']
puts " -> spec_json_pth: #{spec_json_pth}"
file = File.read(spec_json_pth)
data_hash = JSON.parse(file)
steplib_source_param = ENV['STEPLIB_SOURCE']
puts " -> steplib_source_param: #{steplib_source_param}"
data_hash['steplib_source'] = steplib_source_param
File.write(spec_json_pth, JSON.pretty_generate(data_hash))
puts "DONE - OK"
- runner_bin: ruby
- script:
title: Generate
dependencies:
- manager: brew
name: s3cmd
inputs:
- content: |-
#!/bin/bash
set -e
set -v
bash ./_scripts/deploy/deploy.sh
quicktest:
description: |-
A workflow for testing quick bitrise.yml changes
after_run:
- _notifications