@cloudsnorkel/cdk-github-runners 0.0.14 → 0.2.0
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/.jsii +101 -85
- package/API.md +46 -31
- package/README.md +21 -15
- package/SETUP_GITHUB.md +58 -29
- package/demo-thumbnail.jpg +0 -0
- package/lib/index.d.ts +0 -1
- package/lib/lambdas/delete-runner/index.js +32 -18
- package/lib/lambdas/setup/index.js +9103 -0
- package/lib/lambdas/status/index.js +78 -39
- package/lib/lambdas/token-retriever/index.js +23 -13
- package/lib/lambdas/webhook-handler/index.js +23 -8
- package/lib/providers/codebuild.d.ts +1 -2
- package/lib/providers/codebuild.js +3 -2
- package/lib/providers/common.d.ts +0 -1
- package/lib/providers/common.js +1 -1
- package/lib/providers/fargate.d.ts +13 -1
- package/lib/providers/fargate.js +28 -4
- package/lib/providers/lambda.d.ts +0 -1
- package/lib/providers/lambda.js +1 -1
- package/lib/runner.d.ts +3 -14
- package/lib/runner.js +34 -25
- package/lib/secrets.d.ts +5 -2
- package/lib/secrets.js +12 -5
- package/lib/utils.d.ts +0 -1
- package/lib/webhook.d.ts +0 -1
- package/package.json +11 -10
- package/changelog.md +0 -7
- package/lib/index.d.ts.map +0 -1
- package/lib/providers/codebuild.d.ts.map +0 -1
- package/lib/providers/common.d.ts.map +0 -1
- package/lib/providers/fargate.d.ts.map +0 -1
- package/lib/providers/lambda.d.ts.map +0 -1
- package/lib/runner.d.ts.map +0 -1
- package/lib/secrets.d.ts.map +0 -1
- package/lib/utils.d.ts.map +0 -1
- package/lib/webhook.d.ts.map +0 -1
- package/releasetag.txt +0 -1
- package/version.txt +0 -1
package/API.md
CHANGED
|
@@ -322,6 +322,7 @@ Any object.
|
|
|
322
322
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.FargateRunner.property.container">container</a></code> | <code>aws-cdk-lib.aws_ecs.ContainerDefinition</code> | Container definition hosting the runner. |
|
|
323
323
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.FargateRunner.property.grantPrincipal">grantPrincipal</a></code> | <code>aws-cdk-lib.aws_iam.IPrincipal</code> | Grant principal used to add permissions to the runner role. |
|
|
324
324
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.FargateRunner.property.label">label</a></code> | <code>string</code> | Label associated with this provider. |
|
|
325
|
+
| <code><a href="#@cloudsnorkel/cdk-github-runners.FargateRunner.property.spot">spot</a></code> | <code>boolean</code> | Use spot pricing for Fargate tasks. |
|
|
325
326
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.FargateRunner.property.task">task</a></code> | <code>aws-cdk-lib.aws_ecs.FargateTaskDefinition</code> | Fargate task hosting the runner. |
|
|
326
327
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.FargateRunner.property.securityGroup">securityGroup</a></code> | <code>aws-cdk-lib.aws_ec2.ISecurityGroup</code> | Security group attached to the task. |
|
|
327
328
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.FargateRunner.property.vpc">vpc</a></code> | <code>aws-cdk-lib.aws_ec2.IVpc</code> | VPC used for hosting the task. |
|
|
@@ -412,6 +413,18 @@ Label associated with this provider.
|
|
|
412
413
|
|
|
413
414
|
---
|
|
414
415
|
|
|
416
|
+
##### `spot`<sup>Required</sup> <a name="spot" id="@cloudsnorkel/cdk-github-runners.FargateRunner.property.spot"></a>
|
|
417
|
+
|
|
418
|
+
```typescript
|
|
419
|
+
public readonly spot: boolean;
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
- *Type:* boolean
|
|
423
|
+
|
|
424
|
+
Use spot pricing for Fargate tasks.
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
415
428
|
##### `task`<sup>Required</sup> <a name="task" id="@cloudsnorkel/cdk-github-runners.FargateRunner.property.task"></a>
|
|
416
429
|
|
|
417
430
|
```typescript
|
|
@@ -488,7 +501,6 @@ new GitHubRunners(
|
|
|
488
501
|
'runners',
|
|
489
502
|
{
|
|
490
503
|
providers: [myProvider],
|
|
491
|
-
defaultProviderLabel: 'my-codebuild',
|
|
492
504
|
}
|
|
493
505
|
);
|
|
494
506
|
```
|
|
@@ -574,7 +586,6 @@ Any object.
|
|
|
574
586
|
| **Name** | **Type** | **Description** |
|
|
575
587
|
| --- | --- | --- |
|
|
576
588
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.GitHubRunners.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
|
|
577
|
-
| <code><a href="#@cloudsnorkel/cdk-github-runners.GitHubRunners.property.defaultProvider">defaultProvider</a></code> | <code><a href="#@cloudsnorkel/cdk-github-runners.IRunnerProvider">IRunnerProvider</a></code> | Default provider as set by {@link GitHubRunnersProps.defaultProviderLabel}. |
|
|
578
589
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.GitHubRunners.property.props">props</a></code> | <code><a href="#@cloudsnorkel/cdk-github-runners.GitHubRunnersProps">GitHubRunnersProps</a></code> | *No description.* |
|
|
579
590
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.GitHubRunners.property.providers">providers</a></code> | <code><a href="#@cloudsnorkel/cdk-github-runners.IRunnerProvider">IRunnerProvider</a>[]</code> | Configured runner providers. |
|
|
580
591
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.GitHubRunners.property.secrets">secrets</a></code> | <code><a href="#@cloudsnorkel/cdk-github-runners.Secrets">Secrets</a></code> | Secrets for GitHub communication including webhook secret and runner authentication. |
|
|
@@ -593,18 +604,6 @@ The tree node.
|
|
|
593
604
|
|
|
594
605
|
---
|
|
595
606
|
|
|
596
|
-
##### `defaultProvider`<sup>Required</sup> <a name="defaultProvider" id="@cloudsnorkel/cdk-github-runners.GitHubRunners.property.defaultProvider"></a>
|
|
597
|
-
|
|
598
|
-
```typescript
|
|
599
|
-
public readonly defaultProvider: IRunnerProvider;
|
|
600
|
-
```
|
|
601
|
-
|
|
602
|
-
- *Type:* <a href="#@cloudsnorkel/cdk-github-runners.IRunnerProvider">IRunnerProvider</a>
|
|
603
|
-
|
|
604
|
-
Default provider as set by {@link GitHubRunnersProps.defaultProviderLabel}.
|
|
605
|
-
|
|
606
|
-
---
|
|
607
|
-
|
|
608
607
|
##### `props`<sup>Required</sup> <a name="props" id="@cloudsnorkel/cdk-github-runners.GitHubRunners.property.props"></a>
|
|
609
608
|
|
|
610
609
|
```typescript
|
|
@@ -924,6 +923,7 @@ Any object.
|
|
|
924
923
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.Secrets.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
|
|
925
924
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.Secrets.property.github">github</a></code> | <code>aws-cdk-lib.aws_secretsmanager.Secret</code> | Authentication secret for GitHub containing either app details or personal authentication token. |
|
|
926
925
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.Secrets.property.githubPrivateKey">githubPrivateKey</a></code> | <code>aws-cdk-lib.aws_secretsmanager.Secret</code> | GitHub app private key. Not needed when using personal authentication tokens. |
|
|
926
|
+
| <code><a href="#@cloudsnorkel/cdk-github-runners.Secrets.property.setup">setup</a></code> | <code>aws-cdk-lib.aws_secretsmanager.Secret</code> | Setup secret used to authenticate user for our setup wizard. |
|
|
927
927
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.Secrets.property.webhook">webhook</a></code> | <code>aws-cdk-lib.aws_secretsmanager.Secret</code> | Webhook secret used to confirm events are coming from GitHub and nowhere else. |
|
|
928
928
|
|
|
929
929
|
---
|
|
@@ -967,7 +967,21 @@ public readonly githubPrivateKey: Secret;
|
|
|
967
967
|
|
|
968
968
|
GitHub app private key. Not needed when using personal authentication tokens.
|
|
969
969
|
|
|
970
|
-
This secret is meant to be edited by the user after being created.
|
|
970
|
+
This secret is meant to be edited by the user after being created. It is separate than the main GitHub secret because inserting private keys into JSON is hard.
|
|
971
|
+
|
|
972
|
+
---
|
|
973
|
+
|
|
974
|
+
##### `setup`<sup>Required</sup> <a name="setup" id="@cloudsnorkel/cdk-github-runners.Secrets.property.setup"></a>
|
|
975
|
+
|
|
976
|
+
```typescript
|
|
977
|
+
public readonly setup: Secret;
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
- *Type:* aws-cdk-lib.aws_secretsmanager.Secret
|
|
981
|
+
|
|
982
|
+
Setup secret used to authenticate user for our setup wizard.
|
|
983
|
+
|
|
984
|
+
Should be empty after setup has been completed.
|
|
971
985
|
|
|
972
986
|
---
|
|
973
987
|
|
|
@@ -1149,6 +1163,7 @@ const fargateRunnerProps: FargateRunnerProps = { ... }
|
|
|
1149
1163
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.FargateRunnerProps.property.label">label</a></code> | <code>string</code> | GitHub Actions label used for this provider. |
|
|
1150
1164
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.FargateRunnerProps.property.memoryLimitMiB">memoryLimitMiB</a></code> | <code>number</code> | The amount (in MiB) of memory used by the task. |
|
|
1151
1165
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.FargateRunnerProps.property.securityGroup">securityGroup</a></code> | <code>aws-cdk-lib.aws_ec2.ISecurityGroup</code> | Security Group to assign to the task. |
|
|
1166
|
+
| <code><a href="#@cloudsnorkel/cdk-github-runners.FargateRunnerProps.property.spot">spot</a></code> | <code>boolean</code> | Use Fargate spot capacity provider to save money. |
|
|
1152
1167
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.FargateRunnerProps.property.vpc">vpc</a></code> | <code>aws-cdk-lib.aws_ec2.IVpc</code> | VPC to launch the runners in. |
|
|
1153
1168
|
|
|
1154
1169
|
---
|
|
@@ -1307,6 +1322,22 @@ Security Group to assign to the task.
|
|
|
1307
1322
|
|
|
1308
1323
|
---
|
|
1309
1324
|
|
|
1325
|
+
##### `spot`<sup>Optional</sup> <a name="spot" id="@cloudsnorkel/cdk-github-runners.FargateRunnerProps.property.spot"></a>
|
|
1326
|
+
|
|
1327
|
+
```typescript
|
|
1328
|
+
public readonly spot: boolean;
|
|
1329
|
+
```
|
|
1330
|
+
|
|
1331
|
+
- *Type:* boolean
|
|
1332
|
+
- *Default:* false
|
|
1333
|
+
|
|
1334
|
+
Use Fargate spot capacity provider to save money.
|
|
1335
|
+
|
|
1336
|
+
* Runners may fail to start due to missing capacity.
|
|
1337
|
+
* Runners might be stopped prematurely with spot pricing.
|
|
1338
|
+
|
|
1339
|
+
---
|
|
1340
|
+
|
|
1310
1341
|
##### `vpc`<sup>Optional</sup> <a name="vpc" id="@cloudsnorkel/cdk-github-runners.FargateRunnerProps.property.vpc"></a>
|
|
1311
1342
|
|
|
1312
1343
|
```typescript
|
|
@@ -1336,26 +1367,10 @@ const gitHubRunnersProps: GitHubRunnersProps = { ... }
|
|
|
1336
1367
|
|
|
1337
1368
|
| **Name** | **Type** | **Description** |
|
|
1338
1369
|
| --- | --- | --- |
|
|
1339
|
-
| <code><a href="#@cloudsnorkel/cdk-github-runners.GitHubRunnersProps.property.defaultProviderLabel">defaultProviderLabel</a></code> | <code>string</code> | Label of default provider in case the workflow job doesn't specify any known label. |
|
|
1340
1370
|
| <code><a href="#@cloudsnorkel/cdk-github-runners.GitHubRunnersProps.property.providers">providers</a></code> | <code><a href="#@cloudsnorkel/cdk-github-runners.IRunnerProvider">IRunnerProvider</a>[]</code> | List of runner providers to use. |
|
|
1341
1371
|
|
|
1342
1372
|
---
|
|
1343
1373
|
|
|
1344
|
-
##### `defaultProviderLabel`<sup>Optional</sup> <a name="defaultProviderLabel" id="@cloudsnorkel/cdk-github-runners.GitHubRunnersProps.property.defaultProviderLabel"></a>
|
|
1345
|
-
|
|
1346
|
-
```typescript
|
|
1347
|
-
public readonly defaultProviderLabel: string;
|
|
1348
|
-
```
|
|
1349
|
-
|
|
1350
|
-
- *Type:* string
|
|
1351
|
-
- *Default:* 'codebuild'
|
|
1352
|
-
|
|
1353
|
-
Label of default provider in case the workflow job doesn't specify any known label.
|
|
1354
|
-
|
|
1355
|
-
A provider with that label must be configured.
|
|
1356
|
-
|
|
1357
|
-
---
|
|
1358
|
-
|
|
1359
1374
|
##### `providers`<sup>Optional</sup> <a name="providers" id="@cloudsnorkel/cdk-github-runners.GitHubRunnersProps.property.providers"></a>
|
|
1360
1375
|
|
|
1361
1376
|
```typescript
|
package/README.md
CHANGED
|
@@ -10,32 +10,36 @@
|
|
|
10
10
|
|
|
11
11
|
Use this CDK construct to create ephemeral [self-hosted GitHub runners][1] on-demand inside your AWS account.
|
|
12
12
|
|
|
13
|
-
* Easy to configure GitHub integration
|
|
13
|
+
* Easy to configure GitHub integration with a web-based interface
|
|
14
14
|
* Customizable runners with decent defaults
|
|
15
|
-
*
|
|
15
|
+
* Multiple runner configurations controlled by labels
|
|
16
16
|
* Everything fully hosted in your account
|
|
17
17
|
|
|
18
18
|
Self-hosted runners in AWS are useful when:
|
|
19
19
|
|
|
20
20
|
* You need easy access to internal resources in your actions
|
|
21
21
|
* You want to pre-install some software for your actions
|
|
22
|
-
* You want to provide some basic AWS API access ([aws-actions/configure-aws-credentials][2] has more security controls)
|
|
22
|
+
* You want to provide some basic AWS API access (but [aws-actions/configure-aws-credentials][2] has more security controls)
|
|
23
23
|
|
|
24
|
-
Ephemeral runners are the [recommended way by GitHub][14] for auto-scaling, and they make sure all jobs run with a clean image. Runners are started on-demand. You don't pay unless a job is running.
|
|
24
|
+
Ephemeral (or on-demand) runners are the [recommended way by GitHub][14] for auto-scaling, and they make sure all jobs run with a clean image. Runners are started on-demand. You don't pay unless a job is running.
|
|
25
25
|
|
|
26
26
|
## API
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
The best way to browse API documentation is on [Constructs Hub][13]. It is available in all supported programming languages.
|
|
29
29
|
|
|
30
30
|
## Providers
|
|
31
31
|
|
|
32
32
|
A runner provider creates compute resources on-demand and uses [actions/runner][5] to start a runner.
|
|
33
33
|
|
|
34
|
-
|
|
|
35
|
-
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
34
|
+
| | CodeBuild | Fargate | Lambda |
|
|
35
|
+
|----------------|--------------------------|---------------|---------------|
|
|
36
|
+
| **Time limit** | 8 hours | Unlimited | 15 minutes |
|
|
37
|
+
| **vCPUs** | 2, 4, 8, or 72 | 0.25 to 4 | 1 to 6 |
|
|
38
|
+
| **RAM** | 3gb, 7gb, 15gb, or 145gb | 512mb to 30gb | 128mb to 10gb |
|
|
39
|
+
| **Storage** | 50gb to 824gb | 20gb to 200gb | Up to 10gb |
|
|
40
|
+
| **sudo** | ✔ | ✔ | ❌ |
|
|
41
|
+
| **Docker** | ✔ | ❌ | ❌ |
|
|
42
|
+
| **Spot** | ❌ | ✔ | ❌ |
|
|
39
43
|
|
|
40
44
|
The best provider to use mostly depends on your current infrastructure. When in doubt, CodeBuild is always a good choice. Execution history and logs are easy to view, and it has no restrictive limits unless you need to run for more than 8 hours.
|
|
41
45
|
|
|
@@ -72,14 +76,16 @@ You can also create your own provider by implementing `IRunnerProvider`.
|
|
|
72
76
|
4. Deploy your stack
|
|
73
77
|
5. Look for the status command output similar to `aws --region us-east-1 lambda invoke --function-name status-XYZ123 status.json`
|
|
74
78
|
6. Execute the status command (you may need to specify `--profile` too) and open the resulting `status.json` file
|
|
75
|
-
7. [
|
|
79
|
+
7. Open the URL in `github.setup.url` from `status.json` or [manually setup GitHub](SETUP_GITHUB.md) integration as an app or with personal access token
|
|
76
80
|
8. Run status command again to confirm `github.auth.status` and `github.webhook.status` are OK
|
|
77
81
|
9. Trigger a GitHub action that has a `self-hosted` label with `runs-on: [self-hosted, linux, codebuild]` or similar
|
|
78
82
|
10. If the action is not successful, see [troubleshooting](#Troubleshooting)
|
|
79
83
|
|
|
84
|
+
[](https://youtu.be/wlyv_3V8lIw)
|
|
85
|
+
|
|
80
86
|
## Customizing
|
|
81
87
|
|
|
82
|
-
The default providers configured by
|
|
88
|
+
The default providers configured by `GitHubRunners` are useful for testing but probably not too much for actual production work. They run in the default VPC or no VPC and have no added IAM permissions. You would usually want to configure the providers yourself.
|
|
83
89
|
|
|
84
90
|
For example:
|
|
85
91
|
|
|
@@ -124,7 +130,6 @@ new GitHubRunners(
|
|
|
124
130
|
'runners',
|
|
125
131
|
{
|
|
126
132
|
providers: [myProvider],
|
|
127
|
-
defaultProviderLabel: 'my-codebuild',
|
|
128
133
|
}
|
|
129
134
|
);
|
|
130
135
|
|
|
@@ -140,8 +145,9 @@ app.synth();
|
|
|
140
145
|
1. Always start with the status function, make sure no errors are reported, and confirm all status codes are OK
|
|
141
146
|
2. Confirm the webhook Lambda was called by visiting the URL in `troubleshooting.webhookHandlerUrl` from `status.json`
|
|
142
147
|
1. If it's not called or logs errors, confirm the webhook settings on the GitHub side
|
|
143
|
-
2. If you see too many errors, make sure you're only sending `workflow_job` events
|
|
144
|
-
3.
|
|
148
|
+
2. If you see too many errors, make sure you're only sending `workflow_job` events
|
|
149
|
+
3. When using GitHub app, make sure there are active installation in `github.auth.app.installations`
|
|
150
|
+
4. Check execution details of the orchestrator step function by visiting the URL in `troubleshooting.stepFunctionUrl` from `status.json`
|
|
145
151
|
1. Use the details tab to find the specific execution of the provider (Lambda, CodeBuild, Fargate, etc.)
|
|
146
152
|
2. Every step function execution should be successful, even if the runner action inside it failed
|
|
147
153
|
|
package/SETUP_GITHUB.md
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
# Setup GitHub
|
|
2
2
|
|
|
3
|
-
Integration with GitHub can be done using an [app]
|
|
3
|
+
Integration with GitHub can be done using an [app](#app-authentication) or [personal access token](#personal-access-token). Using an app allows more fine-grained access control. Using an app is easier with the setup wizard.
|
|
4
4
|
|
|
5
5
|
## App Authentication
|
|
6
6
|
|
|
7
|
+
### Setup Wizard
|
|
8
|
+
|
|
9
|
+
1. Open the URL in `github.setup.url` from `status.json`
|
|
10
|
+
2. If you want to create an app for your personal repositories, click the Create button under New Personal App
|
|
11
|
+
3. If you want to create an app for your organization:
|
|
12
|
+
1. Find the New Organization App section
|
|
13
|
+
2. Type in the organization name in organization slug (ORGANIZATION from https://github.com/ORGANIZATION/REPO)
|
|
14
|
+
3. Click the Create button
|
|
15
|
+
4. Follow the instructions on GitHub
|
|
16
|
+
5. When brought back to the setup wizard, click the install link
|
|
17
|
+
6. Install the new app on your desired repositories
|
|
18
|
+
|
|
19
|
+
### Manually
|
|
20
|
+
|
|
7
21
|
1. Decide if you want to create a personal app or an organization app
|
|
8
22
|
1. For a personal app use https://github.com/settings/apps/new
|
|
9
23
|
2. For an organization app use https://github.com/organizations/MY_ORG/settings/apps/new after replacing `MY_ORG` with your GitHub organization name
|
|
@@ -18,19 +32,11 @@ Integration with GitHub can be done using an [app][9] or [personal access token]
|
|
|
18
32
|
1. Workflow job
|
|
19
33
|
6. Under "Where can this GitHub App be installed?" select "Only on this account"
|
|
20
34
|
7. Click the Create button
|
|
21
|
-
8. From the new app page
|
|
22
|
-
|
|
23
|
-
2. Click generate new client secret and write it down
|
|
24
|
-
3. Generate a private key and save the downloaded key
|
|
25
|
-
9. On the top left go to Install App page and:
|
|
26
|
-
1. Install the app on the desired account or organization
|
|
27
|
-
2. Copy the installation id number from the URL and write it down (e.g. if the URL is https://github.com/settings/installations/123456, your installation id is 123456)
|
|
35
|
+
8. From the new app page generate a private key and save the downloaded key
|
|
36
|
+
9. On the top left go to Install App page and install the app on the desired account or organization
|
|
28
37
|
10. Open the URL in `github.auth.secretUrl` from `status.json` and edit the secret value
|
|
29
38
|
1. If you're using a self-hosted GitHub instance, put its domain in `domain` (e.g. `github.mycompany.com`)
|
|
30
39
|
2. Put the new application id in `appId` (e.g. `34789562`)
|
|
31
|
-
3. Put the client id in `clientId` (e.g. `Iv1.0beef123456`)
|
|
32
|
-
4. Put the client secret in `clientSecret` (e.g. `4e2b66fab69065001500697b0d751beb033a3deb`)
|
|
33
|
-
5. Put the installation id you copied from the URL in `installationId` (e.g. `123456`)
|
|
34
40
|
6. Ignore/delete `dummy` and **leave `personalAuthToken` empty**
|
|
35
41
|
11. Open the URL in `github.auth.privateKeySecretUrl` from `status.json` and edit the secret value
|
|
36
42
|
1. Open the downloaded private key with any text editor
|
|
@@ -38,21 +44,44 @@ Integration with GitHub can be done using an [app][9] or [personal access token]
|
|
|
38
44
|
|
|
39
45
|
## Personal Access Token
|
|
40
46
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
### Create Token
|
|
48
|
+
|
|
49
|
+
1. Go to https://github.com/settings/tokens/new
|
|
50
|
+
2. Choose your expiration date (you will need to replace the token if it expires)
|
|
51
|
+
3. Under scopes select `repo`
|
|
52
|
+
4. Copy the generated token
|
|
53
|
+
|
|
54
|
+
### Set Token
|
|
55
|
+
|
|
56
|
+
#### Setup Wizard
|
|
57
|
+
|
|
58
|
+
1. Open the URL in `github.setup.url` from `status.json`
|
|
59
|
+
2. Enter your personal access token under Using Personal Access Token
|
|
60
|
+
3. Click the Set button
|
|
61
|
+
|
|
62
|
+
#### Manually
|
|
63
|
+
|
|
64
|
+
1. Open the URL in `github.auth.secretUrl` from `status.json` and edit the secret value
|
|
65
|
+
2. If you're using a self-hosted GitHub instance, put its domain in `domain` (e.g. `github.mycompany.com`)
|
|
66
|
+
3. Put the generated token in `personalAuthToken`
|
|
67
|
+
4. Ignore all other values
|
|
68
|
+
|
|
69
|
+
### Setup Webhook
|
|
70
|
+
|
|
71
|
+
1. For organizations go to https://github.com/organizations/MY_ORG/settings/hooks after replacing `MY_ORG` with your GitHub organization name
|
|
72
|
+
2. For enterprise go to https://github.com/enterprises/MY_ENTERPRISE/settings/hooks after replacing `MY_ENTERPRISE` with your GitHub enterprise name
|
|
73
|
+
3. Otherwise, you can create one per repository in your repository settings under Webhooks
|
|
74
|
+
4. Configure the webhook:
|
|
75
|
+
1. For Webhook URL use the value of `github.webhook.url` from `status.json`
|
|
76
|
+
2. Open the URL in `github.webhook.secretUrl` from `status.json`, retrieve the secret value, and use it for webhook secret
|
|
77
|
+
3. Make sure content type is set to JSON
|
|
78
|
+
4. Select individual jobs and select only Workflow jobs
|
|
79
|
+
|
|
80
|
+
## Resetting Setup Wizard
|
|
81
|
+
|
|
82
|
+
If the setup wizard tells you setup has already been completed or if `github.setup.status` is completed, or if `github.setup.url` is empty:
|
|
83
|
+
|
|
84
|
+
1. Open the URL in `github.setup.secretUrl` from `status.json`
|
|
85
|
+
2. Edit the secret
|
|
86
|
+
3. Put a new random value in `token`
|
|
87
|
+
4. Run status function again to get the new URL
|
|
Binary file
|
package/lib/index.d.ts
CHANGED
|
@@ -4,4 +4,3 @@ export { CodeBuildRunner, CodeBuildRunnerProps } from './providers/codebuild';
|
|
|
4
4
|
export { LambdaRunner, LambdaRunnerProps } from './providers/lambda';
|
|
5
5
|
export { FargateRunner, FargateRunnerProps } from './providers/fargate';
|
|
6
6
|
export { IRunnerProvider, RunnerProviderProps, RunnerVersion, RunnerRuntimeParameters } from './providers/common';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -12509,33 +12510,42 @@ var require_dist_node15 = __commonJS({
|
|
|
12509
12510
|
// src/lambdas/github.ts
|
|
12510
12511
|
var import_auth_app = __toESM(require_dist_node12());
|
|
12511
12512
|
var import_core = __toESM(require_dist_node15());
|
|
12513
|
+
|
|
12514
|
+
// src/lambdas/helpers.ts
|
|
12512
12515
|
var AWS = __toESM(require("aws-sdk"));
|
|
12513
12516
|
var sm = new AWS.SecretsManager();
|
|
12517
|
+
async function getSecretValue(arn) {
|
|
12518
|
+
if (!arn) {
|
|
12519
|
+
throw new Error("Missing secret ARN");
|
|
12520
|
+
}
|
|
12521
|
+
const secret = await sm.getSecretValue({ SecretId: arn }).promise();
|
|
12522
|
+
if (!secret.SecretString) {
|
|
12523
|
+
throw new Error(`No SecretString in ${arn}`);
|
|
12524
|
+
}
|
|
12525
|
+
return secret.SecretString;
|
|
12526
|
+
}
|
|
12527
|
+
async function getSecretJsonValue(arn) {
|
|
12528
|
+
return JSON.parse(await getSecretValue(arn));
|
|
12529
|
+
}
|
|
12530
|
+
|
|
12531
|
+
// src/lambdas/github.ts
|
|
12514
12532
|
function baseUrlFromDomain(domain) {
|
|
12515
12533
|
if (domain == "github.com") {
|
|
12516
12534
|
return "https://api.github.com";
|
|
12517
12535
|
}
|
|
12518
12536
|
return `https://${domain}/api/v3`;
|
|
12519
12537
|
}
|
|
12520
|
-
async function getOctokit() {
|
|
12538
|
+
async function getOctokit(installationId) {
|
|
12521
12539
|
if (!process.env.GITHUB_SECRET_ARN || !process.env.GITHUB_PRIVATE_KEY_SECRET_ARN) {
|
|
12522
12540
|
throw new Error("Missing environment variables");
|
|
12523
12541
|
}
|
|
12524
|
-
const
|
|
12525
|
-
SecretId: process.env.GITHUB_SECRET_ARN
|
|
12526
|
-
}).promise();
|
|
12527
|
-
if (!secret.SecretString) {
|
|
12528
|
-
throw new Error(`No secret string in ${process.env.GITHUB_SECRET_ARN}`);
|
|
12529
|
-
}
|
|
12530
|
-
const githubSecrets = JSON.parse(secret.SecretString);
|
|
12542
|
+
const githubSecrets = await getSecretJsonValue(process.env.GITHUB_SECRET_ARN);
|
|
12531
12543
|
let baseUrl = baseUrlFromDomain(githubSecrets.domain);
|
|
12532
12544
|
let token;
|
|
12533
12545
|
if (githubSecrets.personalAuthToken) {
|
|
12534
12546
|
token = githubSecrets.personalAuthToken;
|
|
12535
12547
|
} else {
|
|
12536
|
-
const privateKey =
|
|
12537
|
-
SecretId: process.env.GITHUB_PRIVATE_KEY_SECRET_ARN
|
|
12538
|
-
}).promise()).SecretString;
|
|
12548
|
+
const privateKey = await getSecretValue(process.env.GITHUB_PRIVATE_KEY_SECRET_ARN);
|
|
12539
12549
|
const appOctokit = new import_core.Octokit({
|
|
12540
12550
|
baseUrl,
|
|
12541
12551
|
authStrategy: import_auth_app.createAppAuth,
|
|
@@ -12546,7 +12556,7 @@ async function getOctokit() {
|
|
|
12546
12556
|
});
|
|
12547
12557
|
token = (await appOctokit.auth({
|
|
12548
12558
|
type: "installation",
|
|
12549
|
-
installationId
|
|
12559
|
+
installationId
|
|
12550
12560
|
})).token;
|
|
12551
12561
|
}
|
|
12552
12562
|
const octokit = new import_core.Octokit({
|
|
@@ -12580,12 +12590,16 @@ async function getRunnerId(octokit, owner, repo, name) {
|
|
|
12580
12590
|
}
|
|
12581
12591
|
}
|
|
12582
12592
|
exports.handler = async function(event) {
|
|
12583
|
-
const { octokit } = await getOctokit();
|
|
12584
|
-
|
|
12585
|
-
|
|
12586
|
-
|
|
12587
|
-
|
|
12588
|
-
|
|
12593
|
+
const { octokit } = await getOctokit(event.installationId);
|
|
12594
|
+
try {
|
|
12595
|
+
await octokit.request("POST /repos/{owner}/{repo}/actions/runs/{runId}/cancel", {
|
|
12596
|
+
owner: event.owner,
|
|
12597
|
+
repo: event.repo,
|
|
12598
|
+
runId: event.runId
|
|
12599
|
+
});
|
|
12600
|
+
} catch (e) {
|
|
12601
|
+
console.error(`Unable to cancel workflow: ${e}`);
|
|
12602
|
+
}
|
|
12589
12603
|
const runnerId = await getRunnerId(octokit, event.owner, event.repo, event.runnerName);
|
|
12590
12604
|
if (!runnerId) {
|
|
12591
12605
|
console.error(`Unable to find runner id for ${event.owner}/${event.repo}:${event.runnerName}`);
|