@cloudsnorkel/cdk-github-runners 0.11.3 → 0.11.5
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 +1 -1
- package/.jsii +127 -93
- package/API.md +29 -2
- package/SETUP_GITHUB.md +9 -5
- package/assets/delete-failed-runner.lambda/index.js +55 -45
- package/assets/docker-images/lambda/linux-arm64/runner.js +1 -0
- package/assets/docker-images/lambda/linux-arm64/runner.sh +1 -1
- package/assets/docker-images/lambda/linux-x64/runner.js +1 -0
- package/assets/docker-images/lambda/linux-x64/runner.sh +1 -1
- package/assets/idle-runner-repear.lambda/index.js +65 -55
- package/assets/image-builders/aws-image-builder/delete-ami.lambda/index.js +14 -28
- package/assets/image-builders/aws-image-builder/filter-failed-builds.lambda/index.js +4 -14
- package/assets/image-builders/aws-image-builder/reaper.lambda/index.js +18 -30
- package/assets/image-builders/aws-image-builder/versioner.lambda/index.js +10 -16
- package/assets/providers/ami-root-device.lambda/index.js +12 -23
- package/assets/providers/build-image.lambda/index.js +16 -24
- package/assets/providers/update-lambda.lambda/index.js +5 -15
- package/assets/setup.lambda/index.html +20 -12
- package/assets/setup.lambda/index.js +17 -12
- package/assets/status.lambda/index.js +50 -55
- package/assets/token-retriever.lambda/index.js +51 -39
- package/assets/webhook-handler.lambda/index.js +32 -42
- package/lib/access.js +1 -1
- package/lib/delete-failed-runner-function.js +2 -2
- package/lib/delete-failed-runner.lambda.js +4 -8
- package/lib/idle-runner-repear-function.js +2 -2
- package/lib/idle-runner-repear.lambda.js +16 -19
- package/lib/image-builders/api.js +1 -1
- package/lib/image-builders/aws-image-builder/builder.js +1 -1
- package/lib/image-builders/aws-image-builder/delete-ami-function.js +2 -2
- package/lib/image-builders/aws-image-builder/delete-ami.lambda.js +11 -11
- package/lib/image-builders/aws-image-builder/deprecated/ami.js +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/container.js +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/linux-components.js +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/windows-components.js +1 -1
- package/lib/image-builders/aws-image-builder/filter-failed-builds-function.js +2 -2
- package/lib/image-builders/aws-image-builder/filter-failed-builds.lambda.js +5 -5
- package/lib/image-builders/aws-image-builder/reaper-function.js +2 -2
- package/lib/image-builders/aws-image-builder/reaper.lambda.js +15 -13
- package/lib/image-builders/aws-image-builder/versioner-function.js +2 -2
- package/lib/image-builders/aws-image-builder/versioner.lambda.js +9 -9
- package/lib/image-builders/codebuild-deprecated.js +1 -1
- package/lib/image-builders/components.js +1 -1
- package/lib/image-builders/static.js +1 -1
- package/lib/lambda-github.d.ts +16 -13
- package/lib/lambda-github.js +33 -8
- package/lib/lambda-helpers.js +5 -5
- package/lib/providers/ami-root-device-function.js +2 -2
- package/lib/providers/ami-root-device.lambda.js +8 -7
- package/lib/providers/build-image-function.js +2 -2
- package/lib/providers/build-image.lambda.js +15 -13
- package/lib/providers/codebuild.js +10 -5
- package/lib/providers/common.d.ts +5 -1
- package/lib/providers/common.js +4 -4
- package/lib/providers/ec2.js +56 -17
- package/lib/providers/ecs.d.ts +7 -1
- package/lib/providers/ecs.js +8 -3
- package/lib/providers/fargate.js +12 -8
- package/lib/providers/lambda.js +4 -3
- package/lib/providers/update-lambda-function.js +2 -2
- package/lib/providers/update-lambda.lambda.js +6 -6
- package/lib/runner.js +6 -2
- package/lib/secrets.js +4 -2
- package/lib/setup-function.js +2 -2
- package/lib/setup.lambda.js +13 -7
- package/lib/status-function.js +2 -2
- package/lib/status.lambda.js +23 -17
- package/lib/token-retriever-function.js +2 -2
- package/lib/token-retriever.lambda.d.ts +2 -1
- package/lib/token-retriever.lambda.js +30 -8
- package/lib/webhook-handler-function.js +2 -2
- package/lib/webhook-handler.lambda.js +5 -5
- package/package.json +21 -10
package/API.md
CHANGED
|
@@ -6048,6 +6048,7 @@ const ecsRunnerProviderProps: EcsRunnerProviderProps = { ... }
|
|
|
6048
6048
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.EcsRunnerProviderProps.property.labels">labels</a></code> | <code>string[]</code> | GitHub Actions labels used for this provider. |
|
|
6049
6049
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.EcsRunnerProviderProps.property.maxInstances">maxInstances</a></code> | <code>number</code> | The maximum number of instances to run in the cluster. |
|
|
6050
6050
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.EcsRunnerProviderProps.property.memoryLimitMiB">memoryLimitMiB</a></code> | <code>number</code> | The amount (in MiB) of memory used by the task. |
|
|
6051
|
+
| <code><a href="#@cloudsnorkel/cdk-github-runners.EcsRunnerProviderProps.property.memoryReservationMiB">memoryReservationMiB</a></code> | <code>number</code> | The soft limit (in MiB) of memory to reserve for the container. |
|
|
6051
6052
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.EcsRunnerProviderProps.property.minInstances">minInstances</a></code> | <code>number</code> | The minimum number of instances to run in the cluster. |
|
|
6052
6053
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.EcsRunnerProviderProps.property.securityGroups">securityGroups</a></code> | <code>aws-cdk-lib.aws_ec2.ISecurityGroup[]</code> | Security groups to assign to the task. |
|
|
6053
6054
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.EcsRunnerProviderProps.property.spot">spot</a></code> | <code>boolean</code> | Use spot capacity. |
|
|
@@ -6230,12 +6231,25 @@ public readonly memoryLimitMiB: number;
|
|
|
6230
6231
|
```
|
|
6231
6232
|
|
|
6232
6233
|
- *Type:* number
|
|
6233
|
-
- *Default:* 3500
|
|
6234
|
+
- *Default:* 3500, unless `memoryReservationMiB` is used and then it's undefined
|
|
6234
6235
|
|
|
6235
6236
|
The amount (in MiB) of memory used by the task.
|
|
6236
6237
|
|
|
6237
6238
|
---
|
|
6238
6239
|
|
|
6240
|
+
##### `memoryReservationMiB`<sup>Optional</sup> <a name="memoryReservationMiB" id="@cloudsnorkel/cdk-github-runners.EcsRunnerProviderProps.property.memoryReservationMiB"></a>
|
|
6241
|
+
|
|
6242
|
+
```typescript
|
|
6243
|
+
public readonly memoryReservationMiB: number;
|
|
6244
|
+
```
|
|
6245
|
+
|
|
6246
|
+
- *Type:* number
|
|
6247
|
+
- *Default:* undefined
|
|
6248
|
+
|
|
6249
|
+
The soft limit (in MiB) of memory to reserve for the container.
|
|
6250
|
+
|
|
6251
|
+
---
|
|
6252
|
+
|
|
6239
6253
|
##### `minInstances`<sup>Optional</sup> <a name="minInstances" id="@cloudsnorkel/cdk-github-runners.EcsRunnerProviderProps.property.minInstances"></a>
|
|
6240
6254
|
|
|
6241
6255
|
```typescript
|
|
@@ -7978,7 +7992,7 @@ public readonly retryOptions: ProviderRetryOptions;
|
|
|
7978
7992
|
Workflow job parameters as parsed from the webhook event. Pass these into your runner executor and run something like:.
|
|
7979
7993
|
|
|
7980
7994
|
```sh
|
|
7981
|
-
./config.sh --unattended --url "
|
|
7995
|
+
./config.sh --unattended --url "{REGISTRATION_URL}" --token "${RUNNER_TOKEN}" --ephemeral --work _work --labels "${RUNNER_LABEL}" --name "${RUNNER_NAME}" --disableupdate
|
|
7982
7996
|
```
|
|
7983
7997
|
|
|
7984
7998
|
All parameters are specified as step function paths and therefore must be used only in step function task parameters.
|
|
@@ -7997,6 +8011,7 @@ const runnerRuntimeParameters: RunnerRuntimeParameters = { ... }
|
|
|
7997
8011
|
| --- | --- | --- |
|
|
7998
8012
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerRuntimeParameters.property.githubDomainPath">githubDomainPath</a></code> | <code>string</code> | Path to GitHub domain. |
|
|
7999
8013
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerRuntimeParameters.property.ownerPath">ownerPath</a></code> | <code>string</code> | Path to repository owner name. |
|
|
8014
|
+
| <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerRuntimeParameters.property.registrationUrl">registrationUrl</a></code> | <code>string</code> | Repository or organization URL to register runner at. |
|
|
8000
8015
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerRuntimeParameters.property.repoPath">repoPath</a></code> | <code>string</code> | Path to repository name. |
|
|
8001
8016
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerRuntimeParameters.property.runnerNamePath">runnerNamePath</a></code> | <code>string</code> | Path to desired runner name. |
|
|
8002
8017
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerRuntimeParameters.property.runnerTokenPath">runnerTokenPath</a></code> | <code>string</code> | Path to runner token used to register token. |
|
|
@@ -8029,6 +8044,18 @@ Path to repository owner name.
|
|
|
8029
8044
|
|
|
8030
8045
|
---
|
|
8031
8046
|
|
|
8047
|
+
##### `registrationUrl`<sup>Required</sup> <a name="registrationUrl" id="@cloudsnorkel/cdk-github-runners.RunnerRuntimeParameters.property.registrationUrl"></a>
|
|
8048
|
+
|
|
8049
|
+
```typescript
|
|
8050
|
+
public readonly registrationUrl: string;
|
|
8051
|
+
```
|
|
8052
|
+
|
|
8053
|
+
- *Type:* string
|
|
8054
|
+
|
|
8055
|
+
Repository or organization URL to register runner at.
|
|
8056
|
+
|
|
8057
|
+
---
|
|
8058
|
+
|
|
8032
8059
|
##### `repoPath`<sup>Required</sup> <a name="repoPath" id="@cloudsnorkel/cdk-github-runners.RunnerRuntimeParameters.property.repoPath"></a>
|
|
8033
8060
|
|
|
8034
8061
|
```typescript
|
package/SETUP_GITHUB.md
CHANGED
|
@@ -13,6 +13,7 @@ Integration with GitHub can be done using an [app](#app-authentication) or [pers
|
|
|
13
13
|
5. If you want to create an app for your organization:
|
|
14
14
|
1. Choose Organization app
|
|
15
15
|
2. Type in the organization slug (ORGANIZATION from https://github.com/ORGANIZATION/REPO)
|
|
16
|
+
3. Choose registration level for the runners
|
|
16
17
|
6. Click Create GitHub App to take you to GitHub to finish the setup
|
|
17
18
|
7. Follow the instructions on GitHub
|
|
18
19
|
8. When brought back to the setup wizard, click the install link
|
|
@@ -27,10 +28,12 @@ Integration with GitHub can be done using an [app](#app-authentication) or [pers
|
|
|
27
28
|
3. Setup webhook under the webhook section
|
|
28
29
|
1. For Webhook URL use the value of `github.webhook.url` from `status.json`
|
|
29
30
|
2. Open the URL in `github.webhook.secretUrl` from `status.json`, retrieve the secret value, and use it for webhook secret
|
|
30
|
-
4. In the
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
4. In the permissions section enable:
|
|
32
|
+
1. Repository -> Actions: Read and write
|
|
33
|
+
2. Repository -> Administration: Read and write
|
|
34
|
+
3. Repository -> Deployments: Read-only
|
|
35
|
+
4. Repository -> Administration: Read and write (only for repository level runners)
|
|
36
|
+
5. Organization -> Self-hosted runners: Read and write (only for organization level runners)
|
|
34
37
|
5. In the event subscription section enable:
|
|
35
38
|
1. Workflow job
|
|
36
39
|
6. Under "Where can this GitHub App be installed?" select "Only on this account"
|
|
@@ -40,7 +43,8 @@ Integration with GitHub can be done using an [app](#app-authentication) or [pers
|
|
|
40
43
|
10. Open the URL in `github.auth.secretUrl` from `status.json` and edit the secret value
|
|
41
44
|
1. If you're using a self-hosted GitHub instance, put its domain in `domain` (e.g. `github.mycompany.com`)
|
|
42
45
|
2. Put the new application id in `appId` (e.g. `34789562`)
|
|
43
|
-
3.
|
|
46
|
+
3. If using organization level registration, add `runnerLevel` with `org` as the value
|
|
47
|
+
4. Ignore/delete `dummy` and **leave `personalAuthToken` empty**
|
|
44
48
|
11. Open the URL in `github.auth.privateKeySecretUrl` from `status.json` and edit the secret value
|
|
45
49
|
1. Open the downloaded private key with any text editor
|
|
46
50
|
2. Copy the text from the private key as-is into the secret
|
|
@@ -12865,7 +12865,6 @@ var require_cjs = __commonJS({
|
|
|
12865
12865
|
};
|
|
12866
12866
|
var AC = globalThis.AbortController;
|
|
12867
12867
|
var AS = globalThis.AbortSignal;
|
|
12868
|
-
var _a;
|
|
12869
12868
|
if (typeof AC === "undefined") {
|
|
12870
12869
|
AS = class AbortSignal {
|
|
12871
12870
|
onabort;
|
|
@@ -12882,7 +12881,6 @@ var require_cjs = __commonJS({
|
|
|
12882
12881
|
}
|
|
12883
12882
|
signal = new AS();
|
|
12884
12883
|
abort(reason) {
|
|
12885
|
-
var _a2, _b;
|
|
12886
12884
|
if (this.signal.aborted)
|
|
12887
12885
|
return;
|
|
12888
12886
|
this.signal.reason = reason;
|
|
@@ -12890,10 +12888,10 @@ var require_cjs = __commonJS({
|
|
|
12890
12888
|
for (const fn of this.signal._onabort) {
|
|
12891
12889
|
fn(reason);
|
|
12892
12890
|
}
|
|
12893
|
-
|
|
12891
|
+
this.signal.onabort?.(reason);
|
|
12894
12892
|
}
|
|
12895
12893
|
};
|
|
12896
|
-
let printACPolyfillWarning =
|
|
12894
|
+
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1";
|
|
12897
12895
|
const warnACPolyfill = () => {
|
|
12898
12896
|
if (!printACPolyfillWarning)
|
|
12899
12897
|
return;
|
|
@@ -13548,7 +13546,6 @@ var require_cjs = __commonJS({
|
|
|
13548
13546
|
* {@link LRUCache#delete}
|
|
13549
13547
|
*/
|
|
13550
13548
|
set(k, v, setOptions = {}) {
|
|
13551
|
-
var _a2, _b, _c;
|
|
13552
13549
|
if (v === void 0) {
|
|
13553
13550
|
this.delete(k);
|
|
13554
13551
|
return this;
|
|
@@ -13586,10 +13583,10 @@ var require_cjs = __commonJS({
|
|
|
13586
13583
|
oldVal.__abortController.abort(new Error("replaced"));
|
|
13587
13584
|
} else if (!noDisposeOnSet) {
|
|
13588
13585
|
if (this.#hasDispose) {
|
|
13589
|
-
|
|
13586
|
+
this.#dispose?.(oldVal, k, "set");
|
|
13590
13587
|
}
|
|
13591
13588
|
if (this.#hasDisposeAfter) {
|
|
13592
|
-
|
|
13589
|
+
this.#disposed?.push([oldVal, k, "set"]);
|
|
13593
13590
|
}
|
|
13594
13591
|
}
|
|
13595
13592
|
this.#removeItemSize(index);
|
|
@@ -13618,8 +13615,8 @@ var require_cjs = __commonJS({
|
|
|
13618
13615
|
if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
|
|
13619
13616
|
const dt = this.#disposed;
|
|
13620
13617
|
let task;
|
|
13621
|
-
while (task = dt
|
|
13622
|
-
|
|
13618
|
+
while (task = dt?.shift()) {
|
|
13619
|
+
this.#disposeAfter?.(...task);
|
|
13623
13620
|
}
|
|
13624
13621
|
}
|
|
13625
13622
|
return this;
|
|
@@ -13629,7 +13626,6 @@ var require_cjs = __commonJS({
|
|
|
13629
13626
|
* `undefined` if cache is empty.
|
|
13630
13627
|
*/
|
|
13631
13628
|
pop() {
|
|
13632
|
-
var _a2;
|
|
13633
13629
|
try {
|
|
13634
13630
|
while (this.#size) {
|
|
13635
13631
|
const val = this.#valList[this.#head];
|
|
@@ -13646,14 +13642,13 @@ var require_cjs = __commonJS({
|
|
|
13646
13642
|
if (this.#hasDisposeAfter && this.#disposed) {
|
|
13647
13643
|
const dt = this.#disposed;
|
|
13648
13644
|
let task;
|
|
13649
|
-
while (task = dt
|
|
13650
|
-
|
|
13645
|
+
while (task = dt?.shift()) {
|
|
13646
|
+
this.#disposeAfter?.(...task);
|
|
13651
13647
|
}
|
|
13652
13648
|
}
|
|
13653
13649
|
}
|
|
13654
13650
|
}
|
|
13655
13651
|
#evict(free) {
|
|
13656
|
-
var _a2, _b;
|
|
13657
13652
|
const head = this.#head;
|
|
13658
13653
|
const k = this.#keyList[head];
|
|
13659
13654
|
const v = this.#valList[head];
|
|
@@ -13661,10 +13656,10 @@ var require_cjs = __commonJS({
|
|
|
13661
13656
|
v.__abortController.abort(new Error("evicted"));
|
|
13662
13657
|
} else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
13663
13658
|
if (this.#hasDispose) {
|
|
13664
|
-
|
|
13659
|
+
this.#dispose?.(v, k, "evict");
|
|
13665
13660
|
}
|
|
13666
13661
|
if (this.#hasDisposeAfter) {
|
|
13667
|
-
|
|
13662
|
+
this.#disposed?.push([v, k, "evict"]);
|
|
13668
13663
|
}
|
|
13669
13664
|
}
|
|
13670
13665
|
this.#removeItemSize(head);
|
|
@@ -13739,7 +13734,7 @@ var require_cjs = __commonJS({
|
|
|
13739
13734
|
}
|
|
13740
13735
|
const ac = new AC();
|
|
13741
13736
|
const { signal } = options;
|
|
13742
|
-
signal
|
|
13737
|
+
signal?.addEventListener("abort", () => ac.abort(signal.reason), {
|
|
13743
13738
|
signal: ac.signal
|
|
13744
13739
|
});
|
|
13745
13740
|
const fetchOpts = {
|
|
@@ -13810,8 +13805,7 @@ var require_cjs = __commonJS({
|
|
|
13810
13805
|
}
|
|
13811
13806
|
};
|
|
13812
13807
|
const pcall = (res, rej) => {
|
|
13813
|
-
|
|
13814
|
-
const fmp = (_a2 = this.#fetchMethod) == null ? void 0 : _a2.call(this, k, v, fetchOpts);
|
|
13808
|
+
const fmp = this.#fetchMethod?.(k, v, fetchOpts);
|
|
13815
13809
|
if (fmp && fmp instanceof Promise) {
|
|
13816
13810
|
fmp.then((v2) => res(v2), rej);
|
|
13817
13811
|
}
|
|
@@ -14000,7 +13994,6 @@ var require_cjs = __commonJS({
|
|
|
14000
13994
|
* Returns true if the key was deleted, false otherwise.
|
|
14001
13995
|
*/
|
|
14002
13996
|
delete(k) {
|
|
14003
|
-
var _a2, _b, _c, _d;
|
|
14004
13997
|
let deleted = false;
|
|
14005
13998
|
if (this.#size !== 0) {
|
|
14006
13999
|
const index = this.#keyMap.get(k);
|
|
@@ -14015,10 +14008,10 @@ var require_cjs = __commonJS({
|
|
|
14015
14008
|
v.__abortController.abort(new Error("deleted"));
|
|
14016
14009
|
} else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
14017
14010
|
if (this.#hasDispose) {
|
|
14018
|
-
|
|
14011
|
+
this.#dispose?.(v, k, "delete");
|
|
14019
14012
|
}
|
|
14020
14013
|
if (this.#hasDisposeAfter) {
|
|
14021
|
-
|
|
14014
|
+
this.#disposed?.push([v, k, "delete"]);
|
|
14022
14015
|
}
|
|
14023
14016
|
}
|
|
14024
14017
|
this.#keyMap.delete(k);
|
|
@@ -14037,11 +14030,11 @@ var require_cjs = __commonJS({
|
|
|
14037
14030
|
}
|
|
14038
14031
|
}
|
|
14039
14032
|
}
|
|
14040
|
-
if (this.#hasDisposeAfter &&
|
|
14033
|
+
if (this.#hasDisposeAfter && this.#disposed?.length) {
|
|
14041
14034
|
const dt = this.#disposed;
|
|
14042
14035
|
let task;
|
|
14043
|
-
while (task = dt
|
|
14044
|
-
|
|
14036
|
+
while (task = dt?.shift()) {
|
|
14037
|
+
this.#disposeAfter?.(...task);
|
|
14045
14038
|
}
|
|
14046
14039
|
}
|
|
14047
14040
|
return deleted;
|
|
@@ -14050,7 +14043,6 @@ var require_cjs = __commonJS({
|
|
|
14050
14043
|
* Clear the cache entirely, throwing away all values.
|
|
14051
14044
|
*/
|
|
14052
14045
|
clear() {
|
|
14053
|
-
var _a2, _b, _c;
|
|
14054
14046
|
for (const index of this.#rindexes({ allowStale: true })) {
|
|
14055
14047
|
const v = this.#valList[index];
|
|
14056
14048
|
if (this.#isBackgroundFetch(v)) {
|
|
@@ -14058,10 +14050,10 @@ var require_cjs = __commonJS({
|
|
|
14058
14050
|
} else {
|
|
14059
14051
|
const k = this.#keyList[index];
|
|
14060
14052
|
if (this.#hasDispose) {
|
|
14061
|
-
|
|
14053
|
+
this.#dispose?.(v, k, "delete");
|
|
14062
14054
|
}
|
|
14063
14055
|
if (this.#hasDisposeAfter) {
|
|
14064
|
-
|
|
14056
|
+
this.#disposed?.push([v, k, "delete"]);
|
|
14065
14057
|
}
|
|
14066
14058
|
}
|
|
14067
14059
|
}
|
|
@@ -14083,8 +14075,8 @@ var require_cjs = __commonJS({
|
|
|
14083
14075
|
if (this.#hasDisposeAfter && this.#disposed) {
|
|
14084
14076
|
const dt = this.#disposed;
|
|
14085
14077
|
let task;
|
|
14086
|
-
while (task = dt
|
|
14087
|
-
|
|
14078
|
+
while (task = dt?.shift()) {
|
|
14079
|
+
this.#disposeAfter?.(...task);
|
|
14088
14080
|
}
|
|
14089
14081
|
}
|
|
14090
14082
|
}
|
|
@@ -17502,13 +17494,13 @@ var import_auth_app = __toESM(require_dist_node12());
|
|
|
17502
17494
|
var import_rest = __toESM(require_dist_node19());
|
|
17503
17495
|
|
|
17504
17496
|
// src/lambda-helpers.ts
|
|
17505
|
-
var
|
|
17506
|
-
var sm = new
|
|
17497
|
+
var import_client_secrets_manager = require("@aws-sdk/client-secrets-manager");
|
|
17498
|
+
var sm = new import_client_secrets_manager.SecretsManagerClient();
|
|
17507
17499
|
async function getSecretValue(arn) {
|
|
17508
17500
|
if (!arn) {
|
|
17509
17501
|
throw new Error("Missing secret ARN");
|
|
17510
17502
|
}
|
|
17511
|
-
const secret = await sm.
|
|
17503
|
+
const secret = await sm.send(new import_client_secrets_manager.GetSecretValueCommand({ SecretId: arn }));
|
|
17512
17504
|
if (!secret.SecretString) {
|
|
17513
17505
|
throw new Error(`No SecretString in ${arn}`);
|
|
17514
17506
|
}
|
|
@@ -17575,14 +17567,22 @@ async function getOctokit(installationId) {
|
|
|
17575
17567
|
githubSecrets
|
|
17576
17568
|
};
|
|
17577
17569
|
}
|
|
17578
|
-
async function getRunner(octokit, owner, repo, name) {
|
|
17570
|
+
async function getRunner(octokit, runnerLevel, owner, repo, name) {
|
|
17579
17571
|
let page = 1;
|
|
17580
17572
|
while (true) {
|
|
17581
|
-
|
|
17582
|
-
|
|
17583
|
-
|
|
17584
|
-
|
|
17585
|
-
|
|
17573
|
+
let runners;
|
|
17574
|
+
if ((runnerLevel ?? "repo") === "repo") {
|
|
17575
|
+
runners = await octokit.rest.actions.listSelfHostedRunnersForRepo({
|
|
17576
|
+
page,
|
|
17577
|
+
owner,
|
|
17578
|
+
repo
|
|
17579
|
+
});
|
|
17580
|
+
} else {
|
|
17581
|
+
runners = await octokit.rest.actions.listSelfHostedRunnersForOrg({
|
|
17582
|
+
page,
|
|
17583
|
+
org: owner
|
|
17584
|
+
});
|
|
17585
|
+
}
|
|
17586
17586
|
if (runners.data.runners.length == 0) {
|
|
17587
17587
|
return;
|
|
17588
17588
|
}
|
|
@@ -17594,6 +17594,20 @@ async function getRunner(octokit, owner, repo, name) {
|
|
|
17594
17594
|
page++;
|
|
17595
17595
|
}
|
|
17596
17596
|
}
|
|
17597
|
+
async function deleteRunner(octokit, runnerLevel, owner, repo, runnerId) {
|
|
17598
|
+
if ((runnerLevel ?? "repo") === "repo") {
|
|
17599
|
+
await octokit.rest.actions.deleteSelfHostedRunnerFromRepo({
|
|
17600
|
+
owner,
|
|
17601
|
+
repo,
|
|
17602
|
+
runner_id: runnerId
|
|
17603
|
+
});
|
|
17604
|
+
} else {
|
|
17605
|
+
await octokit.rest.actions.deleteSelfHostedRunnerFromOrg({
|
|
17606
|
+
org: owner,
|
|
17607
|
+
runner_id: runnerId
|
|
17608
|
+
});
|
|
17609
|
+
}
|
|
17610
|
+
}
|
|
17597
17611
|
|
|
17598
17612
|
// src/delete-failed-runner.lambda.ts
|
|
17599
17613
|
var RunnerBusy = class _RunnerBusy extends Error {
|
|
@@ -17612,19 +17626,15 @@ var ReraisedError = class _ReraisedError extends Error {
|
|
|
17612
17626
|
}
|
|
17613
17627
|
};
|
|
17614
17628
|
async function handler(event) {
|
|
17615
|
-
const { octokit } = await getOctokit(event.installationId);
|
|
17616
|
-
const runner = await getRunner(octokit, event.owner, event.repo, event.runnerName);
|
|
17629
|
+
const { octokit, githubSecrets } = await getOctokit(event.installationId);
|
|
17630
|
+
const runner = await getRunner(octokit, githubSecrets.runnerLevel, event.owner, event.repo, event.runnerName);
|
|
17617
17631
|
if (!runner) {
|
|
17618
17632
|
console.error(`Unable to find runner id for ${event.owner}/${event.repo}:${event.runnerName}`);
|
|
17619
17633
|
throw new ReraisedError(event);
|
|
17620
17634
|
}
|
|
17621
17635
|
console.log(`Runner ${event.runnerName} has id #${runner.id}`);
|
|
17622
17636
|
try {
|
|
17623
|
-
await octokit.
|
|
17624
|
-
owner: event.owner,
|
|
17625
|
-
repo: event.repo,
|
|
17626
|
-
runner_id: runner.id
|
|
17627
|
-
});
|
|
17637
|
+
await deleteRunner(octokit, githubSecrets.runnerLevel, event.owner, event.repo, runner.id);
|
|
17628
17638
|
} catch (e) {
|
|
17629
17639
|
const reqError = e;
|
|
17630
17640
|
if (reqError.message.includes("is still running a job")) {
|
|
@@ -13,7 +13,7 @@ export HOME=/tmp/home
|
|
|
13
13
|
|
|
14
14
|
# start runner
|
|
15
15
|
if [ "${RUNNER_VERSION}" = "latest" ]; then RUNNER_FLAGS=""; else RUNNER_FLAGS="--disableupdate"; fi
|
|
16
|
-
./config.sh --unattended --url "
|
|
16
|
+
./config.sh --unattended --url "${REGISTRATION_URL}" --token "${RUNNER_TOKEN}" --ephemeral --work _work --labels "${RUNNER_LABEL},cdkghr:started:`date +%s`" --name "${RUNNER_NAME}" ${RUNNER_FLAGS}
|
|
17
17
|
echo Config done
|
|
18
18
|
./run.sh
|
|
19
19
|
echo Run done
|
|
@@ -13,7 +13,7 @@ export HOME=/tmp/home
|
|
|
13
13
|
|
|
14
14
|
# start runner
|
|
15
15
|
if [ "${RUNNER_VERSION}" = "latest" ]; then RUNNER_FLAGS=""; else RUNNER_FLAGS="--disableupdate"; fi
|
|
16
|
-
./config.sh --unattended --url "
|
|
16
|
+
./config.sh --unattended --url "${REGISTRATION_URL}" --token "${RUNNER_TOKEN}" --ephemeral --work _work --labels "${RUNNER_LABEL},cdkghr:started:`date +%s`" --name "${RUNNER_NAME}" ${RUNNER_FLAGS}
|
|
17
17
|
echo Config done
|
|
18
18
|
./run.sh
|
|
19
19
|
echo Run done
|