This repository has been archived by the owner on Nov 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 102
/
.concourse.yml
196 lines (190 loc) · 5.21 KB
/
.concourse.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
resource_types:
- name: pull-request
type: docker-image
source:
repository: jtarchie/pr
- name: pull-request-test
type: docker-image
source:
repository: jtarchie/pr
tag: test
resources:
- name: git-pr
type: git
source:
uri: git@github.com:jtarchie/pullrequest-resource
branch: master
private_key: {{github-private-key}}
- name: docker-pr
type: docker-image
source:
username: {{docker-username}}
password: {{docker-password}}
repository: jtarchie/pr
- name: git-pull-requests
type: pull-request
source:
access_token: {{github-access-token}}
private_key: {{github-private-key}}
repo: jtarchie/github-pullrequest-resource
base: master
- name: merge-pull-requests
type: pull-request-test
source:
access_token: {{github-access-token}}
private_key: {{github-private-key}}
base: test-merge
repo: jtarchie/github-pullrequest-resource
jobs:
- name: create-pr
plan:
- get: git-pr
passed: [ 'docker' ]
trigger: true
- task: create
config:
platform: linux
params:
GITHUB_ACCESS_TOKEN: {{github-access-token}}
image_resource:
type: docker-image
source:
repository: jtarchie/pr
tag: test
run:
path: ruby
args:
- -e
- |
require 'octokit'
Octokit.access_token = ENV['GITHUB_ACCESS_TOKEN']
repo_name = ENV['REPO_NAME'] || 'jtarchie/pullrequest-resource'
base_branch = ENV['BASE_BRANCH'] || 'test-merge'
test_branch = "test-merge-#{Time.now.to_i}"
sha = Octokit.ref(repo_name, "heads/#{base_branch}").object.sha
Octokit.create_ref(repo_name, "heads/#{test_branch}", sha)
blob_sha = Octokit.contents(
repo_name,
path: 'README.md',
ref: test_branch
).sha
Octokit.update_contents(
repo_name,
'README.md',
'Updating content',
blob_sha,
"File content #{Time.now.to_s}",
branch: test_branch
)
Octokit.create_pull_request(
repo_name,
base_branch,
test_branch,
'testing the latest build',
'testing the latest build'
)
- name: test-pr-merge
plan:
- get: git-pr
passed: [ 'create-pr' ]
- get: merge-pull-requests
trigger: true
- put: merge-pull-requests
params:
path: merge-pull-requests
status: success
merge:
method: merge
commit_msg: merge-pull-requests/README.md
- name: pr tests
plan:
- get: git-pull-requests
trigger: true
version: every
- task: rspec
privileged: true
config:
image_resource:
type: docker-image
source:
repository: jtarchie/pr
tag: test
inputs:
- name: git-pull-requests
platform: linux
run:
path: sh
args: ['-c', 'cd git-pull-requests && bundle install && bundle exec rspec']
on_success:
put: git-pull-requests
params:
path: git-pull-requests
status: success
on_failure:
put: git-pull-requests
params:
path: git-pull-requests
status: failure
- name: docker
plan:
- get: git-pr
trigger: true
- task: tag
config:
image_resource:
type: docker-image
source:
repository: alpine
platform: linux
outputs:
- name: tag
run:
path: sh
args: ["-c", "echo test > tag/name"]
- put: docker-pr
params:
build: git-pr
dockerfile: git-pr/Dockerfile
tag: tag/name
get_params:
skip_download: true
- name: release
plan:
- get: git-pr
passed: [ 'test-pr-merge' ]
- task: next-tag
config:
image_resource:
type: docker-image
source:
repository: concourse/git-resource
platform: linux
inputs:
- name: git-pr
outputs:
- name: tag
run:
path: bash
args:
- -c
- |
set -eux
echo v > tag/prefix
pushd git-pr
git tag -l | sed -e "s/v//" | sort -n | tail -n 1 | xargs -n 1 expr 1 + > ../tag/name
popd
- put: docker-pr
params:
build: git-pr
dockerfile: git-pr/Dockerfile
tag: tag/name
tag_prefix: v
tag_as_latest: true
get_params:
skip_download: true
- put: git-pr
params:
repository: git-pr
only_tag: true
tag: tag/name
tag_prefix: v