@cloudsnorkel/cdk-github-runners 0.2.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +8 -1
- package/.jsii +1371 -206
- package/API.md +1191 -93
- package/README.md +59 -49
- package/lib/index.d.ts +3 -1
- package/lib/index.js +7 -1
- package/lib/lambdas/build-image/index.js +121 -0
- package/lib/lambdas/delete-runner/index.js +5151 -2999
- package/lib/lambdas/setup/index.html +37 -0
- package/lib/lambdas/setup/index.js +140 -255
- package/lib/lambdas/status/index.js +5151 -2999
- package/lib/lambdas/token-retriever/index.js +5151 -2999
- package/lib/lambdas/update-lambda/index.js +55 -0
- package/lib/providers/codebuild.d.ts +31 -1
- package/lib/providers/codebuild.js +57 -13
- package/lib/providers/common.d.ts +87 -6
- package/lib/providers/common.js +64 -4
- package/lib/providers/docker-images/codebuild/linux-arm64/Dockerfile +63 -0
- package/lib/providers/docker-images/codebuild/{Dockerfile → linux-x64/Dockerfile} +14 -5
- package/lib/providers/docker-images/fargate/linux-arm64/Dockerfile +45 -0
- package/lib/providers/docker-images/fargate/{runner.sh → linux-arm64/runner.sh} +0 -0
- package/lib/providers/docker-images/fargate/{Dockerfile → linux-x64/Dockerfile} +14 -5
- package/lib/providers/docker-images/fargate/linux-x64/runner.sh +5 -0
- package/lib/providers/docker-images/lambda/linux-arm64/Dockerfile +36 -0
- package/lib/providers/docker-images/lambda/{runner.js → linux-arm64/runner.js} +0 -0
- package/lib/providers/docker-images/lambda/{runner.sh → linux-arm64/runner.sh} +0 -0
- package/lib/providers/docker-images/lambda/linux-x64/Dockerfile +35 -0
- package/lib/providers/docker-images/lambda/linux-x64/runner.js +29 -0
- package/lib/providers/docker-images/lambda/linux-x64/runner.sh +12 -0
- package/lib/providers/fargate.d.ts +33 -1
- package/lib/providers/fargate.js +39 -8
- package/lib/providers/image-builders/codebuild.d.ts +178 -0
- package/lib/providers/image-builders/codebuild.js +354 -0
- package/lib/providers/image-builders/static.d.ts +29 -0
- package/lib/providers/image-builders/static.js +58 -0
- package/lib/providers/lambda.d.ts +27 -1
- package/lib/providers/lambda.js +88 -9
- package/lib/runner.d.ts +56 -9
- package/lib/runner.js +37 -11
- package/lib/secrets.js +1 -1
- package/lib/utils.d.ts +2 -1
- package/lib/utils.js +14 -3
- package/lib/webhook.js +2 -1
- package/package.json +30 -12
- package/setup/index.html +12 -0
- package/setup/src/App.svelte +291 -0
- package/setup/src/app.scss +15 -0
- package/setup/src/main.ts +8 -0
- package/setup/src/vite-env.d.ts +2 -0
- package/setup/svelte.config.mjs +7 -0
- package/setup/tsconfig.json +21 -0
- package/setup/tsconfig.node.json +8 -0
- package/setup/vite.config.ts +15 -0
- package/lib/providers/docker-images/lambda/Dockerfile +0 -27
package/lib/webhook.js
CHANGED
|
@@ -14,6 +14,7 @@ class GithubWebhookHandler extends constructs_1.Construct {
|
|
|
14
14
|
constructor(scope, id, props) {
|
|
15
15
|
super(scope, id);
|
|
16
16
|
this.handler = new utils_1.BundledNodejsFunction(this, 'webhook-handler', {
|
|
17
|
+
description: 'Handle GitHub webhook and start runner orchestrator',
|
|
17
18
|
environment: {
|
|
18
19
|
STEP_FUNCTION_ARN: props.orchestrator.stateMachineArn,
|
|
19
20
|
WEBHOOK_SECRET_ARN: props.secrets.webhook.secretArn,
|
|
@@ -26,4 +27,4 @@ class GithubWebhookHandler extends constructs_1.Construct {
|
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
exports.GithubWebhookHandler = GithubWebhookHandler;
|
|
29
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
30
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2ViaG9vay5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy93ZWJob29rLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLG1DQUFtQztBQUNuQyx1REFBNkQ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gdGhpcy5oYW5kbGVyLmFkZEZ1bmN0aW9uVXJsKHsgYXV0aFR5cGU6IEZ1bmN0aW9uVXJsQXV0aFR5cGUuTk9ORSB9KS51cmw7XG5cbiAgICBwcm9wcy5zZWNyZXRzLndlYmhvb2suZ3JhbnRSZWFkKHRoaXMuaGFuZGxlcik7XG4gICAgcHJvcHMub3JjaGVzdHJhdG9yLmdyYW50U3RhcnRFeGVjdXRpb24odGhpcy5oYW5kbGVyKTtcbiAgfVxufSJdfQ==
|
package/package.json
CHANGED
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
"docgen": "npx projen docgen",
|
|
16
16
|
"eject": "npx projen eject",
|
|
17
17
|
"eslint": "npx projen eslint",
|
|
18
|
+
"integ:default:assert": "npx projen integ:default:assert",
|
|
19
|
+
"integ:default:deploy": "npx projen integ:default:deploy",
|
|
20
|
+
"integ:default:destroy": "npx projen integ:default:destroy",
|
|
21
|
+
"integ:default:snapshot": "npx projen integ:default:snapshot",
|
|
22
|
+
"integ:default:watch": "npx projen integ:default:watch",
|
|
23
|
+
"integ:snapshot-all": "npx projen integ:snapshot-all",
|
|
18
24
|
"package": "npx projen package",
|
|
19
25
|
"package-all": "npx projen package-all",
|
|
20
26
|
"package:dotnet": "npx projen package:dotnet",
|
|
@@ -40,34 +46,46 @@
|
|
|
40
46
|
"organization": false
|
|
41
47
|
},
|
|
42
48
|
"devDependencies": {
|
|
43
|
-
"@aws-sdk/types": "^3.
|
|
49
|
+
"@aws-sdk/types": "^3.127.0",
|
|
44
50
|
"@octokit/auth-app": "^3.6.1",
|
|
45
51
|
"@octokit/core": "^3.6.0",
|
|
46
52
|
"@octokit/rest": "^18.12.0",
|
|
47
|
-
"@
|
|
53
|
+
"@sveltejs/vite-plugin-svelte": "^1.0.1",
|
|
54
|
+
"@tsconfig/svelte": "^3.0.0",
|
|
55
|
+
"@types/aws-lambda": "^8.10.101",
|
|
56
|
+
"@types/jest": "^27",
|
|
48
57
|
"@types/node": "^14",
|
|
49
58
|
"@typescript-eslint/eslint-plugin": "^5",
|
|
50
59
|
"@typescript-eslint/parser": "^5",
|
|
60
|
+
"aws-cdk": "^2",
|
|
51
61
|
"aws-cdk-lib": "2.21.1",
|
|
52
|
-
"aws-sdk": "^2.
|
|
62
|
+
"aws-sdk": "^2.1181.0",
|
|
63
|
+
"bootstrap": "^5.2.0",
|
|
53
64
|
"constructs": "10.0.5",
|
|
54
|
-
"esbuild": "^0.14.
|
|
65
|
+
"esbuild": "^0.14.49",
|
|
55
66
|
"eslint": "^8",
|
|
56
67
|
"eslint-import-resolver-node": "^0.3.6",
|
|
57
68
|
"eslint-import-resolver-typescript": "^2.7.1",
|
|
58
69
|
"eslint-plugin-import": "^2.26.0",
|
|
59
70
|
"jest": "^27",
|
|
60
71
|
"jest-junit": "^13",
|
|
61
|
-
"jsii": "^1.
|
|
62
|
-
"jsii-diff": "^1.
|
|
72
|
+
"jsii": "^1.62.0",
|
|
73
|
+
"jsii-diff": "^1.62.0",
|
|
63
74
|
"jsii-docgen": "^6.3.27",
|
|
64
|
-
"jsii-pacmak": "^1.
|
|
75
|
+
"jsii-pacmak": "^1.62.0",
|
|
65
76
|
"json-schema": "^0.4.0",
|
|
66
|
-
"npm-check-updates": "^
|
|
67
|
-
"projen": "^0.
|
|
77
|
+
"npm-check-updates": "^15",
|
|
78
|
+
"projen": "^0.60.1",
|
|
79
|
+
"sass": "^1.54.0",
|
|
68
80
|
"standard-version": "^9",
|
|
81
|
+
"svelte": "^3.49.0",
|
|
82
|
+
"svelte-check": "^2.8.0",
|
|
83
|
+
"svelte-preprocess": "^4.10.7",
|
|
69
84
|
"ts-jest": "^27",
|
|
70
|
-
"
|
|
85
|
+
"ts-node": "^10.9.1",
|
|
86
|
+
"typescript": "^4.7.4",
|
|
87
|
+
"vite": "^3.0.0",
|
|
88
|
+
"vite-plugin-singlefile": "^0.11.0"
|
|
71
89
|
},
|
|
72
90
|
"peerDependencies": {
|
|
73
91
|
"aws-cdk-lib": "^2.21.1",
|
|
@@ -87,11 +105,11 @@
|
|
|
87
105
|
],
|
|
88
106
|
"main": "lib/index.js",
|
|
89
107
|
"license": "Apache-2.0",
|
|
90
|
-
"version": "0.2
|
|
108
|
+
"version": "0.3.2",
|
|
91
109
|
"jest": {
|
|
92
110
|
"testMatch": [
|
|
93
111
|
"<rootDir>/src/**/__tests__/**/*.ts?(x)",
|
|
94
|
-
"<rootDir>/(test|src)
|
|
112
|
+
"<rootDir>/(test|src)/**/*(*.)@(spec|test).ts?(x)"
|
|
95
113
|
],
|
|
96
114
|
"clearMocks": true,
|
|
97
115
|
"collectCoverage": true,
|
package/setup/index.html
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Setup GitHub Runners</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="app"></div>
|
|
10
|
+
<script type="module" src="/src/main.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
const secret = 'INSERT_SECRET_ARN_HERE';
|
|
3
|
+
const token = 'INSERT_TOKEN_HERE';
|
|
4
|
+
let instance: undefined | 'github.com' | 'ghes';
|
|
5
|
+
let domain = 'INSERT_DOMAIN_HERE';
|
|
6
|
+
let auth: undefined | 'newApp' | 'existingApp' | 'pat';
|
|
7
|
+
let appScope: 'user' | 'org' = 'user';
|
|
8
|
+
let org = 'ORGANIZATION';
|
|
9
|
+
let existingAppId: string = '';
|
|
10
|
+
let existingAppPk: string = '';
|
|
11
|
+
let pat: string = '';
|
|
12
|
+
let success: boolean;
|
|
13
|
+
let result: string | undefined;
|
|
14
|
+
|
|
15
|
+
const manifest = {
|
|
16
|
+
url: 'https://github.com/CloudSnorkel/cdk-github-runners',
|
|
17
|
+
hook_attributes: {
|
|
18
|
+
url: 'INSERT_WEBHOOK_URL_HERE',
|
|
19
|
+
},
|
|
20
|
+
redirect_url: `INSERT_BASE_URL_HERE/complete-new-app`,
|
|
21
|
+
public: false,
|
|
22
|
+
default_permissions: {
|
|
23
|
+
actions: 'write',
|
|
24
|
+
administration: 'write',
|
|
25
|
+
},
|
|
26
|
+
default_events: [
|
|
27
|
+
'workflow_job',
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function isSubmitDisabled(instance, auth, existingAppId, existingAppPk, pat, success) {
|
|
32
|
+
if (success) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
if (instance === undefined || auth === undefined) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
if (auth === 'newApp') {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (auth === 'existingApp') {
|
|
42
|
+
return existingAppId === '' || existingAppPk === '';
|
|
43
|
+
}
|
|
44
|
+
if (auth === 'pat') {
|
|
45
|
+
return pat === '';
|
|
46
|
+
}
|
|
47
|
+
console.error('Something is broken', instance, auth, existingAppId);
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function submitText(auth) {
|
|
52
|
+
if (auth === 'newApp') {
|
|
53
|
+
return 'Create GitHub App';
|
|
54
|
+
}
|
|
55
|
+
return 'Setup';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function postJson(url, data): Promise<string> {
|
|
59
|
+
return new Promise<string>((resolve, reject) => {
|
|
60
|
+
fetch(`${url}?token=${token}`, {
|
|
61
|
+
method: 'POST',
|
|
62
|
+
mode: 'same-origin',
|
|
63
|
+
headers: {
|
|
64
|
+
'Content-Type': 'application/json',
|
|
65
|
+
},
|
|
66
|
+
body: JSON.stringify(data),
|
|
67
|
+
redirect: 'error',
|
|
68
|
+
})
|
|
69
|
+
.then(response => {
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
response.text()
|
|
72
|
+
.then(text => {
|
|
73
|
+
reject(new Error(`${text} [${response.status}]`));
|
|
74
|
+
})
|
|
75
|
+
.catch(reject);
|
|
76
|
+
} else {
|
|
77
|
+
response.text()
|
|
78
|
+
.then(resolve)
|
|
79
|
+
.catch(reject);
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
.catch(reject);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function submit(ev) {
|
|
87
|
+
ev.preventDefault();
|
|
88
|
+
|
|
89
|
+
function promise(): Promise<string> {
|
|
90
|
+
const rightDomain = instance === 'ghes' ? domain : 'github.com';
|
|
91
|
+
switch (auth) {
|
|
92
|
+
case 'newApp':
|
|
93
|
+
return postJson('domain', { domain: rightDomain })
|
|
94
|
+
.then(_ => {
|
|
95
|
+
(document.getElementById('appform') as HTMLFormElement).submit();
|
|
96
|
+
return Promise.resolve('Redirecting to GitHub...');
|
|
97
|
+
});
|
|
98
|
+
case 'existingApp':
|
|
99
|
+
return postJson('app', {
|
|
100
|
+
appid: existingAppId,
|
|
101
|
+
pk: existingAppPk,
|
|
102
|
+
domain: rightDomain,
|
|
103
|
+
});
|
|
104
|
+
case 'pat':
|
|
105
|
+
return postJson('pat', {
|
|
106
|
+
pat: pat,
|
|
107
|
+
domain: rightDomain,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
promise()
|
|
113
|
+
.then(successText => {
|
|
114
|
+
result = successText;
|
|
115
|
+
success = true;
|
|
116
|
+
})
|
|
117
|
+
.catch(error => {
|
|
118
|
+
result = `${error}`;
|
|
119
|
+
success = false;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
</script>
|
|
123
|
+
|
|
124
|
+
<main>
|
|
125
|
+
<div class="container py-3 px-2">
|
|
126
|
+
<div class="row">
|
|
127
|
+
<form class="col" on:submit={submit}>
|
|
128
|
+
<h1>Setup GitHub Runners</h1>
|
|
129
|
+
<p>Answer all the questions on this page to automatically configure GitHub integration and get the
|
|
130
|
+
runners working. This page will not be accessible once you complete this operation. If you ever want
|
|
131
|
+
to access it again, edit <code>{secret}</code> and run the status function again.</p>
|
|
132
|
+
|
|
133
|
+
<h3>Choose GitHub Instance</h3>
|
|
134
|
+
<div class="px-3 py-3">
|
|
135
|
+
<p>Are your repositories hosted on GitHub.com or are you using an on-premise installation of GitHub
|
|
136
|
+
Enterprise Server?</p>
|
|
137
|
+
<div class="form-check">
|
|
138
|
+
<input class="form-check-input" type="radio" bind:group={instance} value="github.com"
|
|
139
|
+
id="github.com">
|
|
140
|
+
<label class="form-check-label" for="github.com">
|
|
141
|
+
GitHub.com
|
|
142
|
+
</label>
|
|
143
|
+
</div>
|
|
144
|
+
<div class="form-check">
|
|
145
|
+
<input class="form-check-input" type="radio" bind:group={instance} value="ghes" id="ghes">
|
|
146
|
+
<label class="form-check-label" for="ghes">
|
|
147
|
+
GitHub Enterprise Server
|
|
148
|
+
</label>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
|
|
152
|
+
{#if instance === 'ghes'}
|
|
153
|
+
<h3>GitHub Enterprise Server Domain</h3>
|
|
154
|
+
<div class="px-3 py-3">
|
|
155
|
+
<p>Where is GitHub Enterprise Server hosted? Type in the domain without <code>https://</code>
|
|
156
|
+
and without any path. It should look something like <code>github.mycompany.com</code>.</p>
|
|
157
|
+
<input class="form-control" bind:value={domain}>
|
|
158
|
+
</div>
|
|
159
|
+
{/if}
|
|
160
|
+
|
|
161
|
+
{#if instance}
|
|
162
|
+
<h3>Authentication Type</h3>
|
|
163
|
+
<div class="px-3 py-3">
|
|
164
|
+
<p>You can choose between creating a new app that will provide authentication for specific
|
|
165
|
+
repositories, or a personal access token that will provide access to all repositories
|
|
166
|
+
available to you. Apps are easier to set up and provide more fine-grained access control. If
|
|
167
|
+
you have previously created an app, you can choose to use an existing app.</p>
|
|
168
|
+
<div class="form-check">
|
|
169
|
+
<input class="form-check-input" type="radio" bind:group={auth} value="newApp" id="newApp">
|
|
170
|
+
<label class="form-check-label" for="newApp">
|
|
171
|
+
New GitHub App <b>(recommended)</b>
|
|
172
|
+
</label>
|
|
173
|
+
</div>
|
|
174
|
+
<div class="form-check">
|
|
175
|
+
<input class="form-check-input" type="radio" bind:group={auth} value="existingApp"
|
|
176
|
+
id="existingApp">
|
|
177
|
+
<label class="form-check-label" for="existingApp">
|
|
178
|
+
Existing GitHub App
|
|
179
|
+
</label>
|
|
180
|
+
</div>
|
|
181
|
+
<div class="form-check">
|
|
182
|
+
<input class="form-check-input" type="radio" bind:group={auth} value="pat" id="pat">
|
|
183
|
+
<label class="form-check-label" for="pat">
|
|
184
|
+
Personal Authentication Token
|
|
185
|
+
</label>
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
{/if}
|
|
189
|
+
|
|
190
|
+
{#if auth === 'newApp'}
|
|
191
|
+
<h3>New App Settings</h3>
|
|
192
|
+
<div class="px-3 py-3">
|
|
193
|
+
<p>Choose whether to create a new personal app or organization app. A private personal app can
|
|
194
|
+
only be used for repositories under your user. A private origination app can only be used
|
|
195
|
+
for repositories under that organization.</p>
|
|
196
|
+
<div class="form-check">
|
|
197
|
+
<input class="form-check-input" type="radio" bind:group={appScope} value="user"
|
|
198
|
+
id="userScope">
|
|
199
|
+
<label class="form-check-label" for="userScope">
|
|
200
|
+
User app
|
|
201
|
+
</label>
|
|
202
|
+
</div>
|
|
203
|
+
<div class="form-check">
|
|
204
|
+
<input class="form-check-input" type="radio" bind:group={appScope} value="org"
|
|
205
|
+
id="orgScope">
|
|
206
|
+
<label class="form-check-label" for="orgScope">
|
|
207
|
+
Organization app
|
|
208
|
+
</label>
|
|
209
|
+
</div>
|
|
210
|
+
{#if instance === 'ghes'}
|
|
211
|
+
<p class="pt-2">If multiple organizations under the same GitHub Enterprise Server need to use the runners,
|
|
212
|
+
you can make the app public.</p>
|
|
213
|
+
<div class="form-check">
|
|
214
|
+
<input class="form-check-input" type="checkbox" bind:value={manifest.public} id="public">
|
|
215
|
+
<label class="form-check-label" for="public">
|
|
216
|
+
Public app
|
|
217
|
+
</label>
|
|
218
|
+
</div>
|
|
219
|
+
{/if}
|
|
220
|
+
</div>
|
|
221
|
+
|
|
222
|
+
{#if appScope === 'org'}
|
|
223
|
+
<h3>Organization name</h3>
|
|
224
|
+
<div class="px-3 py-3">
|
|
225
|
+
<p>What is the slug for your organization? If your repositories have a URL like
|
|
226
|
+
<code>https://{domain}/MyOrg/my-repo</code>
|
|
227
|
+
then your organization slug is <code>MyOrg</code>.</p>
|
|
228
|
+
<input class="form-control" bind:value={org}>
|
|
229
|
+
</div>
|
|
230
|
+
{/if}
|
|
231
|
+
{:else if auth === 'existingApp'}
|
|
232
|
+
<h3>Existing App Details</h3>
|
|
233
|
+
<div class="px-3 py-3">
|
|
234
|
+
<p>Existing apps must have <code>actions</code> and <code>administration</code> write
|
|
235
|
+
permissions. Don't forget to set up the webhook and its secret as described in <a
|
|
236
|
+
href="https://github.com/CloudSnorkel/cdk-github-runners/blob/main/SETUP_GITHUB.md">SETUP_GITHUB.md</a>.
|
|
237
|
+
</p>
|
|
238
|
+
<div class="form-group row px-3 py-2">
|
|
239
|
+
<label for="appid" class="col-sm-2 col-form-label">App Id</label>
|
|
240
|
+
<div class="col-sm-10">
|
|
241
|
+
<input type="number" class="form-control" id="appid" bind:value={existingAppId}>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
<div class="form-group row px-3 py-2">
|
|
245
|
+
<label for="pk" class="col-sm-2 col-form-label">Private Key</label>
|
|
246
|
+
<div class="col-sm-10">
|
|
247
|
+
<textarea class="form-control" id="pk" bind:value={existingAppPk} rows="10"></textarea>
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
</div>
|
|
251
|
+
{:else if auth === 'pat'}
|
|
252
|
+
<h2>Personal Access Token</h2>
|
|
253
|
+
<div class="px-3 py-3">
|
|
254
|
+
<p>The <a href="https://{domain}/settings/tokens">personal access token</a> must have the <code>repo</code>
|
|
255
|
+
scope enabled. Don't forget to also create a webhook as described in <a
|
|
256
|
+
href="https://github.com/CloudSnorkel/cdk-github-runners/blob/main/SETUP_GITHUB.md">SETUP_GITHUB.md</a>.
|
|
257
|
+
</p>
|
|
258
|
+
<input class="form-control" bind:value={pat}
|
|
259
|
+
placeholder="Token e.g. ghp_abcdefghijklmnopqrstuvwxyz1234567890">
|
|
260
|
+
</div>
|
|
261
|
+
{/if}
|
|
262
|
+
|
|
263
|
+
<h2>Finish Setup</h2>
|
|
264
|
+
<div class="px-3 py-3">
|
|
265
|
+
{#if result === undefined}
|
|
266
|
+
<p>This button will be enabled once all the questions above are answered.</p>
|
|
267
|
+
{:else}
|
|
268
|
+
<div class="alert alert-{success ? 'success' : 'danger'}" role="alert">
|
|
269
|
+
{result}
|
|
270
|
+
</div>
|
|
271
|
+
{/if}
|
|
272
|
+
{#if manifest.public && auth === 'newApp'}
|
|
273
|
+
<p><b class="text-danger">WARNING:</b> using a public app means anyone with access to <code>{domain}</code>
|
|
274
|
+
can use the runners you're setting up now. Anyone can create a workflow that will run on those runners,
|
|
275
|
+
have access to their instance profile, and be part of their security group. Consider the security
|
|
276
|
+
implications before continuing.</p>
|
|
277
|
+
{/if}
|
|
278
|
+
<button type="submit" class="btn btn-success"
|
|
279
|
+
disabled={isSubmitDisabled(instance, auth, existingAppId, existingAppPk, pat, success)}>
|
|
280
|
+
{submitText(auth)}
|
|
281
|
+
</button>
|
|
282
|
+
</div>
|
|
283
|
+
</form>
|
|
284
|
+
</div>
|
|
285
|
+
</div>
|
|
286
|
+
|
|
287
|
+
<form action="https://{domain}/{appScope === 'org' ? `organizations/${org}/` : ''}settings/apps/new?state={token}"
|
|
288
|
+
method="post" id="appform">
|
|
289
|
+
<input type="hidden" name="manifest" value={JSON.stringify(manifest)}>
|
|
290
|
+
</form>
|
|
291
|
+
</main>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@import "~bootstrap/scss/functions";
|
|
2
|
+
@import "~bootstrap/scss/variables";
|
|
3
|
+
@import "~bootstrap/scss/mixins";
|
|
4
|
+
@import "~bootstrap/scss/maps";
|
|
5
|
+
@import "~bootstrap/scss/utilities";
|
|
6
|
+
@import "~bootstrap/scss/utilities/api";
|
|
7
|
+
|
|
8
|
+
@import "~bootstrap/scss/root";
|
|
9
|
+
@import "~bootstrap/scss/reboot";
|
|
10
|
+
@import "~bootstrap/scss/type";
|
|
11
|
+
@import "~bootstrap/scss/containers";
|
|
12
|
+
@import "~bootstrap/scss/grid";
|
|
13
|
+
@import "~bootstrap/scss/forms";
|
|
14
|
+
@import "~bootstrap/scss/buttons";
|
|
15
|
+
@import "~bootstrap/scss/alert";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@tsconfig/svelte/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"useDefineForClassFields": true,
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"baseUrl": ".",
|
|
9
|
+
/**
|
|
10
|
+
* Typecheck JS in `.svelte` and `.js` files by default.
|
|
11
|
+
* Disable checkJs if you'd like to use dynamic types in JS.
|
|
12
|
+
* Note that setting allowJs false does not prevent the use
|
|
13
|
+
* of JS in `.svelte` files.
|
|
14
|
+
*/
|
|
15
|
+
"allowJs": true,
|
|
16
|
+
"checkJs": true,
|
|
17
|
+
"isolatedModules": true
|
|
18
|
+
},
|
|
19
|
+
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
|
|
20
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { viteSingleFile } from 'vite-plugin-singlefile';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
// https://vitejs.dev/config/
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
plugins: [svelte(), viteSingleFile()],
|
|
10
|
+
resolve: {
|
|
11
|
+
alias: {
|
|
12
|
+
'~bootstrap': path.resolve(__dirname, '..', 'node_modules/bootstrap'),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
FROM public.ecr.aws/lambda/nodejs:14-x86_64
|
|
2
|
-
|
|
3
|
-
WORKDIR /runner
|
|
4
|
-
|
|
5
|
-
# add dependencies
|
|
6
|
-
RUN yum update -y && yum install -y jq tar gzip bzip2 which binutils git zip unzip
|
|
7
|
-
|
|
8
|
-
# add awscli
|
|
9
|
-
RUN curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o awscliv2.zip && \
|
|
10
|
-
unzip -q awscliv2.zip && ./aws/install && rm -rf awscliv2.zip aws
|
|
11
|
-
|
|
12
|
-
# add ghcli
|
|
13
|
-
RUN GHCLI_URL=`curl -fsSL https://api.github.com/repos/cli/cli/releases/latest | jq -r '.assets | map(select(.name | contains("linux_amd64.rpm"))) |.[0].browser_download_url'` && \
|
|
14
|
-
curl -fsSL "${GHCLI_URL}" -o ghcli.rpm && yum install -y ghcli.rpm && rm -f ghcli.rpm
|
|
15
|
-
|
|
16
|
-
# add runner
|
|
17
|
-
ARG RUNNER_VERSION
|
|
18
|
-
RUN if [ "${RUNNER_VERSION}" = "latest" ]; then RUNNER_VERSION=`curl -fsSL https://api.github.com/repos/actions/runner/releases/latest | jq -r .tag_name | cut -c2-`; fi && \
|
|
19
|
-
curl -fsSLO "https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz" && \
|
|
20
|
-
tar xzf "actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz" && \
|
|
21
|
-
rm -f actions-runner-linux-x64-*.tar.gz \
|
|
22
|
-
RUN ./bin/installdependencies.sh
|
|
23
|
-
|
|
24
|
-
# prepare for execution
|
|
25
|
-
WORKDIR ${LAMBDA_TASK_ROOT}
|
|
26
|
-
COPY runner.js runner.sh ${LAMBDA_TASK_ROOT}
|
|
27
|
-
CMD ["runner.handler"]
|