-
Notifications
You must be signed in to change notification settings - Fork 16
232 lines (202 loc) · 6.06 KB
/
ci.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
---
on:
push:
branches: master
pull_request:
name: release
jobs:
build:
name: build dist/index.js
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install nodejs
uses: actions/setup-node@v2
with:
node-version: "12"
- name: Install dependencies
run: npm ci
- name: Compile action
run: npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v2
with:
name: main
path: dist/index.js
test_create:
name: test secret creation
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Download build artifact
uses: actions/download-artifact@v2
with:
name: main
path: dist
- name: Create a secret
id: self
uses: ./
with:
name: TEST_${{ github.sha }}
value: test
pa_token: ${{ secrets.PA_TOKEN_PIPELINE }}
- name: Assert action output
if: steps.self.outputs.status != '201'
run: echo "::error::Expected HTTP status code 201 got
${{steps.self.outputs.status}}"; exit 1
- name: Confirm secret creation
uses: octokit/[email protected]
with:
route: GET /repos/:repository/actions/secrets/:secret_name
repository: ${{ github.repository }}
secret_name: TEST_${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.PA_TOKEN_PIPELINE }}
- name: Delete secret
if: always()
uses: octokit/[email protected]
with:
route: DELETE /repos/:repository/actions/secrets/:secret_name
repository: ${{ github.repository }}
secret_name: TEST_${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.PA_TOKEN_PIPELINE }}
test_repo_location:
name: test secret creation in foreign repository
runs-on: ubuntu-latest
needs: build
env:
FOREIGN_REPO: gliech/dotfiles
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Download build artifact
uses: actions/download-artifact@v2
with:
name: main
path: dist
- name: Create a secret
id: self
uses: ./
with:
location: ${{ env.FOREIGN_REPO }}
name: TEST_${{ github.sha }}
value: test
pa_token: ${{ secrets.PA_TOKEN_PIPELINE }}
- name: Assert action output
if: steps.self.outputs.status != '201'
run: echo "::error::Expected HTTP status code 201 got
${{steps.self.outputs.status}}"; exit 1
- name: Confirm secret creation
uses: octokit/[email protected]
with:
route: GET /repos/:repository/actions/secrets/:secret_name
repository: ${{ env.FOREIGN_REPO }}
secret_name: TEST_${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.PA_TOKEN_PIPELINE }}
- name: Delete secret
if: always()
uses: octokit/[email protected]
with:
route: DELETE /repos/:repository/actions/secrets/:secret_name
repository: ${{ env.FOREIGN_REPO }}
secret_name: TEST_${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.PA_TOKEN_PIPELINE }}
test_update:
name: test secret update
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Download build artifact
uses: actions/download-artifact@v2
with:
name: main
path: dist
- name: Update a secret
id: self
uses: ./
with:
name: TEST_UPDATE
value: ${{ github.sha }}
pa_token: ${{ secrets.PA_TOKEN_PIPELINE }}
- name: Assert action output
if: steps.self.outputs.status != '204'
run: echo "::error::Expected HTTP status code 204 got
${{steps.self.outputs.status}}"; exit 1
test_organization:
name: test organization secret
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Download build artifact
uses: actions/download-artifact@v2
with:
name: main
path: dist
- name: Update a secret
id: self
uses: ./
with:
location: deinopon
org_visibility: ''
name: CREATE_GITHUB_SECRET_ACTION_TEST
value: ${{ github.sha }}
pa_token: ${{ secrets.PA_TOKEN_ORG_ADMIN }}
- name: Assert action output
if: steps.self.outputs.status != '204'
run: echo "::error::Expected HTTP status code 204 got
${{steps.self.outputs.status}}"; exit 1
release:
name: release new version
if: contains(fromJson('["refs/heads/master","refs/heads/next"]'),
github.ref)
runs-on: ubuntu-latest
needs:
- test_create
- test_repo_location
- test_update
- test_organization
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Download build artifact
uses: actions/download-artifact@v2
with:
name: main
path: dist
- name: Install nodejs
uses: actions/setup-node@v2
with:
node-version: "14"
- name: Install dependencies
run: npm ci
- name: Create new release
run: npm run release
env:
GIT_AUTHOR_NAME: ${{ github.actor }}
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
GIT_COMMITTER_NAME: ${{ github.actor }}
GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com
GITHUB_TOKEN: ${{ secrets.PA_TOKEN_PIPELINE }}
cleanup:
name: cleanup
if: always()
runs-on: ubuntu-latest
needs:
- release
steps:
- name: Delete run artifact
uses: geekyeggo/delete-artifact@v1
with:
name: main