@cloudsnorkel/cdk-github-runners 0.9.3 → 0.9.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.
Files changed (151) hide show
  1. package/.gitattributes +10 -9
  2. package/.jsii +397 -332
  3. package/API.md +56 -9
  4. package/README.md +15 -2
  5. package/assets/{lambdas/delete-runner.lambda → delete-runner.lambda}/index.js +96 -56
  6. package/assets/{lambdas → image-builders/aws-image-builder}/delete-ami.lambda/index.js +3 -3
  7. package/assets/image-builders/aws-image-builder/filter-failed-builds.lambda/index.js +39 -0
  8. package/assets/{lambdas/aws-image-builder-versioner.lambda → image-builders/aws-image-builder/versioner.lambda}/index.js +98 -58
  9. package/assets/{lambdas → providers}/build-image.lambda/index.js +3 -3
  10. package/assets/{lambdas → providers}/update-lambda.lambda/index.js +1 -1
  11. package/assets/{lambdas/setup.lambda → setup.lambda}/index.js +4 -4
  12. package/assets/{lambdas/status.lambda → status.lambda}/index.js +96 -56
  13. package/assets/{lambdas/token-retriever.lambda → token-retriever.lambda}/index.js +96 -56
  14. package/assets/{lambdas/webhook-handler.lambda → webhook-handler.lambda}/index.js +3 -3
  15. package/lib/access.js +1 -1
  16. package/lib/{lambdas/delete-runner-function.d.ts → delete-runner-function.d.ts} +1 -1
  17. package/lib/delete-runner-function.js +23 -0
  18. package/lib/delete-runner.lambda.js +69 -0
  19. package/lib/github.js +50 -0
  20. package/lib/image-builders/api.js +47 -0
  21. package/lib/{providers/image-builders → image-builders}/aws-image-builder/ami.d.ts +2 -3
  22. package/lib/image-builders/aws-image-builder/ami.js +93 -0
  23. package/lib/{providers/image-builders → image-builders}/aws-image-builder/builder.d.ts +21 -5
  24. package/lib/image-builders/aws-image-builder/builder.js +529 -0
  25. package/lib/image-builders/aws-image-builder/common.js +46 -0
  26. package/lib/{providers/image-builders → image-builders}/aws-image-builder/container.d.ts +1 -1
  27. package/lib/image-builders/aws-image-builder/container.js +63 -0
  28. package/lib/{lambdas → image-builders/aws-image-builder}/delete-ami-function.d.ts +1 -1
  29. package/lib/image-builders/aws-image-builder/delete-ami-function.js +23 -0
  30. package/lib/image-builders/aws-image-builder/delete-ami.lambda.js +87 -0
  31. package/lib/{providers/image-builders → image-builders}/aws-image-builder/deprecated/ami.d.ts +2 -3
  32. package/lib/image-builders/aws-image-builder/deprecated/ami.js +240 -0
  33. package/lib/{providers/image-builders → image-builders}/aws-image-builder/deprecated/common.d.ts +1 -1
  34. package/lib/image-builders/aws-image-builder/deprecated/common.js +144 -0
  35. package/lib/{providers/image-builders → image-builders}/aws-image-builder/deprecated/container.d.ts +1 -1
  36. package/lib/image-builders/aws-image-builder/deprecated/container.js +222 -0
  37. package/lib/{providers/image-builders → image-builders}/aws-image-builder/deprecated/index.js +1 -1
  38. package/lib/{providers/image-builders → image-builders}/aws-image-builder/deprecated/linux-components.d.ts +1 -1
  39. package/lib/image-builders/aws-image-builder/deprecated/linux-components.js +172 -0
  40. package/lib/{providers/image-builders → image-builders}/aws-image-builder/deprecated/windows-components.d.ts +1 -1
  41. package/lib/image-builders/aws-image-builder/deprecated/windows-components.js +126 -0
  42. package/lib/image-builders/aws-image-builder/filter-failed-builds-function.d.ts +13 -0
  43. package/lib/image-builders/aws-image-builder/filter-failed-builds-function.js +23 -0
  44. package/lib/image-builders/aws-image-builder/filter-failed-builds.lambda.js +18 -0
  45. package/lib/{providers/image-builders → image-builders}/aws-image-builder/index.js +1 -1
  46. package/lib/image-builders/aws-image-builder/versioner-function.d.ts +13 -0
  47. package/lib/image-builders/aws-image-builder/versioner-function.js +23 -0
  48. package/lib/image-builders/aws-image-builder/versioner.lambda.js +96 -0
  49. package/lib/{providers/image-builders → image-builders}/codebuild-deprecated.d.ts +2 -2
  50. package/lib/image-builders/codebuild-deprecated.js +373 -0
  51. package/lib/{providers/image-builders → image-builders}/codebuild.d.ts +13 -4
  52. package/lib/image-builders/codebuild.js +287 -0
  53. package/lib/{providers/image-builders → image-builders}/common.d.ts +4 -2
  54. package/lib/image-builders/common.js +61 -0
  55. package/lib/{providers/image-builders → image-builders}/components.d.ts +8 -2
  56. package/lib/image-builders/components.js +568 -0
  57. package/lib/{providers/image-builders → image-builders}/index.js +1 -1
  58. package/lib/{providers/image-builders → image-builders}/static.d.ts +1 -1
  59. package/lib/image-builders/static.js +58 -0
  60. package/lib/lambda-helpers.js +66 -0
  61. package/lib/{lambdas → providers}/build-image-function.d.ts +1 -1
  62. package/lib/providers/build-image-function.js +23 -0
  63. package/lib/providers/build-image.lambda.js +92 -0
  64. package/lib/providers/codebuild.d.ts +1 -1
  65. package/lib/providers/codebuild.js +4 -4
  66. package/lib/providers/common.js +3 -3
  67. package/lib/providers/ec2.d.ts +1 -1
  68. package/lib/providers/ec2.js +4 -4
  69. package/lib/providers/ecs.d.ts +1 -1
  70. package/lib/providers/ecs.js +8 -4
  71. package/lib/providers/fargate.d.ts +1 -1
  72. package/lib/providers/fargate.js +4 -4
  73. package/lib/providers/index.d.ts +1 -1
  74. package/lib/providers/index.js +2 -2
  75. package/lib/providers/lambda.d.ts +1 -1
  76. package/lib/providers/lambda.js +5 -5
  77. package/lib/{lambdas → providers}/update-lambda-function.d.ts +1 -1
  78. package/lib/providers/update-lambda-function.js +23 -0
  79. package/lib/providers/update-lambda.lambda.js +34 -0
  80. package/lib/runner.d.ts +9 -1
  81. package/lib/runner.js +24 -12
  82. package/lib/secrets.js +1 -1
  83. package/lib/{lambdas/setup-function.d.ts → setup-function.d.ts} +1 -1
  84. package/lib/setup-function.js +23 -0
  85. package/lib/setup.lambda.js +152 -0
  86. package/lib/{lambdas/status-function.d.ts → status-function.d.ts} +1 -1
  87. package/lib/status-function.js +23 -0
  88. package/lib/status.lambda.js +298 -0
  89. package/lib/{lambdas/token-retriever-function.d.ts → token-retriever-function.d.ts} +1 -1
  90. package/lib/token-retriever-function.js +23 -0
  91. package/lib/token-retriever.lambda.js +15 -0
  92. package/lib/{lambdas/webhook-handler-function.d.ts → webhook-handler-function.d.ts} +1 -1
  93. package/lib/webhook-handler-function.js +23 -0
  94. package/lib/webhook-handler.lambda.d.ts +1 -0
  95. package/lib/webhook-handler.lambda.js +116 -0
  96. package/lib/webhook.d.ts +1 -1
  97. package/lib/webhook.js +2 -2
  98. package/package.json +28 -26
  99. package/lib/lambdas/aws-image-builder-versioner-function.d.ts +0 -13
  100. package/lib/lambdas/aws-image-builder-versioner-function.js +0 -23
  101. package/lib/lambdas/aws-image-builder-versioner.lambda.js +0 -96
  102. package/lib/lambdas/build-image-function.js +0 -23
  103. package/lib/lambdas/build-image.lambda.js +0 -92
  104. package/lib/lambdas/delete-ami-function.js +0 -23
  105. package/lib/lambdas/delete-ami.lambda.js +0 -87
  106. package/lib/lambdas/delete-runner-function.js +0 -23
  107. package/lib/lambdas/delete-runner.lambda.js +0 -69
  108. package/lib/lambdas/github.js +0 -50
  109. package/lib/lambdas/helpers.js +0 -66
  110. package/lib/lambdas/setup-function.js +0 -23
  111. package/lib/lambdas/setup.lambda.js +0 -152
  112. package/lib/lambdas/status-function.js +0 -23
  113. package/lib/lambdas/status.lambda.js +0 -298
  114. package/lib/lambdas/token-retriever-function.js +0 -23
  115. package/lib/lambdas/token-retriever.lambda.js +0 -15
  116. package/lib/lambdas/update-lambda-function.js +0 -23
  117. package/lib/lambdas/update-lambda.lambda.js +0 -34
  118. package/lib/lambdas/webhook-handler-function.js +0 -23
  119. package/lib/lambdas/webhook-handler.lambda.js +0 -116
  120. package/lib/providers/image-builders/api.js +0 -47
  121. package/lib/providers/image-builders/aws-image-builder/ami.js +0 -81
  122. package/lib/providers/image-builders/aws-image-builder/builder.js +0 -488
  123. package/lib/providers/image-builders/aws-image-builder/common.js +0 -46
  124. package/lib/providers/image-builders/aws-image-builder/container.js +0 -63
  125. package/lib/providers/image-builders/aws-image-builder/deprecated/ami.js +0 -239
  126. package/lib/providers/image-builders/aws-image-builder/deprecated/common.js +0 -139
  127. package/lib/providers/image-builders/aws-image-builder/deprecated/container.js +0 -222
  128. package/lib/providers/image-builders/aws-image-builder/deprecated/linux-components.js +0 -180
  129. package/lib/providers/image-builders/aws-image-builder/deprecated/windows-components.js +0 -142
  130. package/lib/providers/image-builders/codebuild-deprecated.js +0 -373
  131. package/lib/providers/image-builders/codebuild.js +0 -271
  132. package/lib/providers/image-builders/common.js +0 -61
  133. package/lib/providers/image-builders/components.js +0 -535
  134. package/lib/providers/image-builders/static.js +0 -58
  135. /package/assets/{lambdas/setup.lambda → setup.lambda}/index.html +0 -0
  136. /package/lib/{lambdas/delete-runner.lambda.d.ts → delete-runner.lambda.d.ts} +0 -0
  137. /package/lib/{lambdas/github.d.ts → github.d.ts} +0 -0
  138. /package/lib/{providers/image-builders → image-builders}/api.d.ts +0 -0
  139. /package/lib/{providers/image-builders → image-builders}/aws-image-builder/common.d.ts +0 -0
  140. /package/lib/{lambdas → image-builders/aws-image-builder}/delete-ami.lambda.d.ts +0 -0
  141. /package/lib/{providers/image-builders → image-builders}/aws-image-builder/deprecated/index.d.ts +0 -0
  142. /package/lib/{lambdas/setup.lambda.d.ts → image-builders/aws-image-builder/filter-failed-builds.lambda.d.ts} +0 -0
  143. /package/lib/{providers/image-builders → image-builders}/aws-image-builder/index.d.ts +0 -0
  144. /package/lib/{lambdas/aws-image-builder-versioner.lambda.d.ts → image-builders/aws-image-builder/versioner.lambda.d.ts} +0 -0
  145. /package/lib/{providers/image-builders → image-builders}/index.d.ts +0 -0
  146. /package/lib/{lambdas/helpers.d.ts → lambda-helpers.d.ts} +0 -0
  147. /package/lib/{lambdas → providers}/build-image.lambda.d.ts +0 -0
  148. /package/lib/{lambdas → providers}/update-lambda.lambda.d.ts +0 -0
  149. /package/lib/{lambdas/status.lambda.d.ts → setup.lambda.d.ts} +0 -0
  150. /package/lib/{lambdas/token-retriever.lambda.d.ts → status.lambda.d.ts} +0 -0
  151. /package/lib/{lambdas/webhook-handler.lambda.d.ts → token-retriever.lambda.d.ts} +0 -0
package/API.md CHANGED
@@ -26,7 +26,6 @@ builder.addComponent(new ImageBuilderComponent(scope, id, {
26
26
  displayName: 'p7zip',
27
27
  description: 'Install some more packages',
28
28
  commands: [
29
- 'set -ex',
30
29
  'apt-get install p7zip',
31
30
  ],
32
31
  }));
@@ -3101,6 +3100,7 @@ new GitHubRunners(scope: Construct, id: string, props?: GitHubRunnersProps)
3101
3100
  | **Name** | **Description** |
3102
3101
  | --- | --- |
3103
3102
  | <code><a href="#@cloudsnorkel/cdk-github-runners.GitHubRunners.toString">toString</a></code> | Returns a string representation of this construct. |
3103
+ | <code><a href="#@cloudsnorkel/cdk-github-runners.GitHubRunners.failedImageBuildsTopic">failedImageBuildsTopic</a></code> | Creates a topic for notifications when a runner image build fails. |
3104
3104
  | <code><a href="#@cloudsnorkel/cdk-github-runners.GitHubRunners.metricFailed">metricFailed</a></code> | Metric for failed runner executions. |
3105
3105
  | <code><a href="#@cloudsnorkel/cdk-github-runners.GitHubRunners.metricJobCompleted">metricJobCompleted</a></code> | Metric for the number of GitHub Actions jobs completed. |
3106
3106
  | <code><a href="#@cloudsnorkel/cdk-github-runners.GitHubRunners.metricSucceeded">metricSucceeded</a></code> | Metric for successful executions. |
@@ -3116,6 +3116,18 @@ public toString(): string
3116
3116
 
3117
3117
  Returns a string representation of this construct.
3118
3118
 
3119
+ ##### `failedImageBuildsTopic` <a name="failedImageBuildsTopic" id="@cloudsnorkel/cdk-github-runners.GitHubRunners.failedImageBuildsTopic"></a>
3120
+
3121
+ ```typescript
3122
+ public failedImageBuildsTopic(): Topic
3123
+ ```
3124
+
3125
+ Creates a topic for notifications when a runner image build fails.
3126
+
3127
+ Runner images are rebuilt every week by default. This provides the latest GitHub Runner version and software updates.
3128
+
3129
+ If you want to be sure you are using the latest runner version, you can use this topic to be notified when a build fails.
3130
+
3119
3131
  ##### `metricFailed` <a name="metricFailed" id="@cloudsnorkel/cdk-github-runners.GitHubRunners.metricFailed"></a>
3120
3132
 
3121
3133
  ```typescript
@@ -3282,8 +3294,8 @@ new ImageBuilderComponent(this, 'AWS CLI', {
3282
3294
  displayName: 'AWS CLI',
3283
3295
  description: 'Install latest version of AWS CLI',
3284
3296
  commands: [
3285
- '$ErrorActionPreference = \'Stop\'',
3286
- 'Start-Process msiexec.exe -Wait -ArgumentList \'/i https://awscli.amazonaws.com/AWSCLIV2.msi /qn\'',
3297
+ '$p = Start-Process msiexec.exe -PassThru -Wait -ArgumentList \'/i https://awscli.amazonaws.com/AWSCLIV2.msi /qn\'',
3298
+ 'if ($p.ExitCode -ne 0) { throw "Exit code is $p.ExitCode" }',
3287
3299
  ],
3288
3300
  }
3289
3301
  ```
@@ -4655,8 +4667,6 @@ public readonly installDocker: boolean;
4655
4667
 
4656
4668
  Install Docker inside the image, so it can be used by the runner.
4657
4669
 
4658
- You may want to disable this if you are building a Windows image and don't have a Docker Desktop license.
4659
-
4660
4670
  ---
4661
4671
 
4662
4672
  ##### `instanceType`<sup>Optional</sup> <a name="instanceType" id="@cloudsnorkel/cdk-github-runners.AmiBuilderProps.property.instanceType"></a>
@@ -4964,7 +4974,7 @@ public readonly buildImage: IBuildImage;
4964
4974
  ```
4965
4975
 
4966
4976
  - *Type:* aws-cdk-lib.aws_codebuild.IBuildImage
4967
- - *Default:* Ubuntu 20.04 for x64 and Amazon Linux 2 for ARM64
4977
+ - *Default:* Ubuntu 22.04 for x64 and Amazon Linux 2 for ARM64
4968
4978
 
4969
4979
  Build image to use in CodeBuild.
4970
4980
 
@@ -5148,7 +5158,7 @@ public readonly buildImage: IBuildImage;
5148
5158
  ```
5149
5159
 
5150
5160
  - *Type:* aws-cdk-lib.aws_codebuild.IBuildImage
5151
- - *Default:* Ubuntu 20.04 for x64 and Amazon Linux 2 for ARM64
5161
+ - *Default:* Ubuntu 22.04 for x64 and Amazon Linux 2 for ARM64
5152
5162
 
5153
5163
  Build image to use in CodeBuild.
5154
5164
 
@@ -6689,6 +6699,7 @@ const imageBuilderComponentProperties: ImageBuilderComponentProperties = { ... }
6689
6699
  | <code><a href="#@cloudsnorkel/cdk-github-runners.ImageBuilderComponentProperties.property.displayName">displayName</a></code> | <code>string</code> | Component display name. |
6690
6700
  | <code><a href="#@cloudsnorkel/cdk-github-runners.ImageBuilderComponentProperties.property.platform">platform</a></code> | <code>string</code> | Component platform. |
6691
6701
  | <code><a href="#@cloudsnorkel/cdk-github-runners.ImageBuilderComponentProperties.property.assets">assets</a></code> | <code><a href="#@cloudsnorkel/cdk-github-runners.ImageBuilderAsset">ImageBuilderAsset</a>[]</code> | Optional assets to add to the built image. |
6702
+ | <code><a href="#@cloudsnorkel/cdk-github-runners.ImageBuilderComponentProperties.property.reboot">reboot</a></code> | <code>boolean</code> | Require a reboot after installing this component. |
6692
6703
 
6693
6704
  ---
6694
6705
 
@@ -6756,6 +6767,19 @@ Optional assets to add to the built image.
6756
6767
 
6757
6768
  ---
6758
6769
 
6770
+ ##### `reboot`<sup>Optional</sup> <a name="reboot" id="@cloudsnorkel/cdk-github-runners.ImageBuilderComponentProperties.property.reboot"></a>
6771
+
6772
+ ```typescript
6773
+ public readonly reboot: boolean;
6774
+ ```
6775
+
6776
+ - *Type:* boolean
6777
+ - *Default:* false
6778
+
6779
+ Require a reboot after installing this component.
6780
+
6781
+ ---
6782
+
6759
6783
  ### LambdaRunnerProviderProps <a name="LambdaRunnerProviderProps" id="@cloudsnorkel/cdk-github-runners.LambdaRunnerProviderProps"></a>
6760
6784
 
6761
6785
  #### Initializer <a name="Initializer" id="@cloudsnorkel/cdk-github-runners.LambdaRunnerProviderProps.Initializer"></a>
@@ -7421,10 +7445,12 @@ public readonly baseAmi: string;
7421
7445
  ```
7422
7446
 
7423
7447
  - *Type:* string
7424
- - *Default:* latest Ubuntu 20.04 AMI for Os.LINUX_UBUNTU, latest Amazon Linux 2 AMI for Os.LINUX_AMAZON_2, latest Windows Server 2022 AMI for Os.WINDOWS
7448
+ - *Default:* latest Ubuntu 22.04 AMI for Os.LINUX_UBUNTU, latest Amazon Linux 2 AMI for Os.LINUX_AMAZON_2, latest Windows Server 2022 AMI for Os.WINDOWS
7425
7449
 
7426
7450
  Base AMI from which runner AMIs will be built.
7427
7451
 
7452
+ This can be an actual AMI or an AWS Image Builder ARN that points to the latest AMI. For example `arn:aws:imagebuilder:us-east-1:aws:image/ubuntu-server-22-lts-x86/x.x.x` would always use the latest version of Ubuntu 22.04 in each build. If you want a specific version, you can replace `x.x.x` with that version.
7453
+
7428
7454
  ---
7429
7455
 
7430
7456
  ##### `baseDockerImage`<sup>Optional</sup> <a name="baseDockerImage" id="@cloudsnorkel/cdk-github-runners.RunnerImageBuilderProps.property.baseDockerImage"></a>
@@ -8432,6 +8458,7 @@ new RunnerImageComponent()
8432
8458
  | <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerImageComponent.getAssets">getAssets</a></code> | Returns assets to copy into the built image. |
8433
8459
  | <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerImageComponent.getCommands">getCommands</a></code> | Returns commands to run to in built image. |
8434
8460
  | <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerImageComponent.getDockerCommands">getDockerCommands</a></code> | Returns Docker commands to run to in built image. |
8461
+ | <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerImageComponent.shouldReboot">shouldReboot</a></code> | Returns true if the image builder should be rebooted after this component is installed. |
8435
8462
 
8436
8463
  ---
8437
8464
 
@@ -8503,6 +8530,26 @@ Docker commands are added after assets and normal commands.
8503
8530
 
8504
8531
  ---
8505
8532
 
8533
+ ##### `shouldReboot` <a name="shouldReboot" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.shouldReboot"></a>
8534
+
8535
+ ```typescript
8536
+ public shouldReboot(_os: Os, _architecture: Architecture): boolean
8537
+ ```
8538
+
8539
+ Returns true if the image builder should be rebooted after this component is installed.
8540
+
8541
+ ###### `_os`<sup>Required</sup> <a name="_os" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.shouldReboot.parameter._os"></a>
8542
+
8543
+ - *Type:* <a href="#@cloudsnorkel/cdk-github-runners.Os">Os</a>
8544
+
8545
+ ---
8546
+
8547
+ ###### `_architecture`<sup>Required</sup> <a name="_architecture" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.shouldReboot.parameter._architecture"></a>
8548
+
8549
+ - *Type:* <a href="#@cloudsnorkel/cdk-github-runners.Architecture">Architecture</a>
8550
+
8551
+ ---
8552
+
8506
8553
  #### Static Functions <a name="Static Functions" id="Static Functions"></a>
8507
8554
 
8508
8555
  | **Name** | **Description** |
@@ -8563,7 +8610,7 @@ RunnerImageComponent.docker()
8563
8610
 
8564
8611
  A component to install Docker.
8565
8612
 
8566
- On Windows this installs Docker Desktop.
8613
+ On Windows this sets up dockerd for Windows containers without Docker Desktop. If you need Linux containers on Windows, you'll need to install Docker Desktop which doesn't seem to play well with servers (PRs welcome).
8567
8614
 
8568
8615
  ##### `dockerInDocker` <a name="dockerInDocker" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.dockerInDocker"></a>
8569
8616
 
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![NPM](https://img.shields.io/npm/v/@cloudsnorkel/cdk-github-runners?label=npm&logo=npm)][7]
4
4
  [![PyPI](https://img.shields.io/pypi/v/cloudsnorkel.cdk-github-runners?label=pypi&logo=pypi)][6]
5
- [![Maven Central](https://img.shields.io/maven-central/v/com.cloudsnorkel/cdk.github.runners.svg?label=Maven%20Central&logo=java)][8]
5
+ [![Maven Central](https://img.shields.io/maven-central/v/com.cloudsnorkel/cdk.github.runners.svg?label=Maven%20Central&logo=apachemaven)][8]
6
6
  [![Go](https://img.shields.io/github/v/tag/CloudSnorkel/cdk-github-runners?color=red&label=go&logo=go)][11]
7
7
  [![Nuget](https://img.shields.io/nuget/v/CloudSnorkel.Cdk.Github.Runners?color=red&&logo=nuget)][12]
8
8
  [![Release](https://github.com/CloudSnorkel/cdk-github-runners/actions/workflows/release.yml/badge.svg)](https://github.com/CloudSnorkel/cdk-github-runners/actions/workflows/release.yml)
@@ -21,6 +21,7 @@ Self-hosted runners in AWS are useful when:
21
21
  * You need easy access to internal resources in your actions
22
22
  * You want to pre-install some software for your actions
23
23
  * You want to provide some basic AWS API access (but [aws-actions/configure-aws-credentials][2] has more security controls)
24
+ * You are using GitHub Enterprise Server
24
25
 
25
26
  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.
26
27
 
@@ -212,7 +213,7 @@ new GitHubRunners(this, 'runners', {
212
213
  1. Always start with the status function, make sure no errors are reported, and confirm all status codes are OK
213
214
  2. If jobs are stuck on pending:
214
215
  1. Make sure `runs-on` in the workflow matches the expected labels set in the runner provider
215
- 2. If it happens every time, cancel the job and start it again
216
+ 2. If jobs get stuck often and take a long time to start, cancel the pending jobs and start them again
216
217
  4. Confirm the webhook Lambda was called by visiting the URL in `troubleshooting.webhookHandlerUrl` from `status.json`
217
218
  1. If it's not called or logs errors, confirm the webhook settings on the GitHub side
218
219
  2. If you see too many errors, make sure you're only sending `workflow_job` events
@@ -221,6 +222,18 @@ new GitHubRunners(this, 'runners', {
221
222
  1. Use the details tab to find the specific execution of the provider (Lambda, CodeBuild, Fargate, etc.)
222
223
  2. Every step function execution should be successful, even if the runner action inside it failed
223
224
 
225
+ ## Monitoring
226
+
227
+ There are two important ways to monitor your runners:
228
+
229
+ 1. Make sure runners don't fail to start. When that happens, jobs may sit and wait. Use `GitHubRunners.metricFailed()` to get a metric for the number of failed runner starts. You should use this metric to trigger an alarm.
230
+ 2. Make sure runner images don't fail to build. Failed runner image builds mean you will get stuck with out-of-date software on your runners. It may lead to security vulnerabilities, or it may lead to slower runner start-ups as the runner software itself needs to be updated. Use `GitHubRunners.failedImageBuildsTopic()` to get SNS topic that gets notified of failed runner image builds. You should subscribe to this topic.
231
+
232
+ Other useful metrics to track:
233
+
234
+ 1. Use `GitHubRunners.metricJobCompleted()` to get a metric for the number of completed jobs broken down by labels and job success.
235
+ 2. Use `GitHubRunners.metricTime()` to get a metric for the total time a runner is running. This includes the overhead of starting the runner.
236
+
224
237
  ## Other Options
225
238
 
226
239
  1. [philips-labs/terraform-aws-github-runner][3] if you're using Terraform
@@ -10172,11 +10172,23 @@ var require_constants = __commonJS({
10172
10172
  var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
10173
10173
  9007199254740991;
10174
10174
  var MAX_SAFE_COMPONENT_LENGTH = 16;
10175
+ var RELEASE_TYPES = [
10176
+ "major",
10177
+ "premajor",
10178
+ "minor",
10179
+ "preminor",
10180
+ "patch",
10181
+ "prepatch",
10182
+ "prerelease"
10183
+ ];
10175
10184
  module2.exports = {
10176
- SEMVER_SPEC_VERSION,
10177
10185
  MAX_LENGTH,
10186
+ MAX_SAFE_COMPONENT_LENGTH,
10178
10187
  MAX_SAFE_INTEGER,
10179
- MAX_SAFE_COMPONENT_LENGTH
10188
+ RELEASE_TYPES,
10189
+ SEMVER_SPEC_VERSION,
10190
+ FLAG_INCLUDE_PRERELEASE: 1,
10191
+ FLAG_LOOSE: 2
10180
10192
  };
10181
10193
  }
10182
10194
  });
@@ -10256,11 +10268,17 @@ var require_re = __commonJS({
10256
10268
  // node_modules/semver/internal/parse-options.js
10257
10269
  var require_parse_options = __commonJS({
10258
10270
  "node_modules/semver/internal/parse-options.js"(exports2, module2) {
10259
- var opts = ["includePrerelease", "loose", "rtl"];
10260
- var parseOptions = (options) => !options ? {} : typeof options !== "object" ? { loose: true } : opts.filter((k) => options[k]).reduce((o, k) => {
10261
- o[k] = true;
10262
- return o;
10263
- }, {});
10271
+ var looseOption = Object.freeze({ loose: true });
10272
+ var emptyOpts = Object.freeze({});
10273
+ var parseOptions = (options) => {
10274
+ if (!options) {
10275
+ return emptyOpts;
10276
+ }
10277
+ if (typeof options !== "object") {
10278
+ return looseOption;
10279
+ }
10280
+ return options;
10281
+ };
10264
10282
  module2.exports = parseOptions;
10265
10283
  }
10266
10284
  });
@@ -10430,31 +10448,31 @@ var require_semver = __commonJS({
10430
10448
  }
10431
10449
  // preminor will bump the version up to the next minor release, and immediately
10432
10450
  // down to pre-release. premajor and prepatch work the same way.
10433
- inc(release, identifier) {
10451
+ inc(release, identifier, identifierBase) {
10434
10452
  switch (release) {
10435
10453
  case "premajor":
10436
10454
  this.prerelease.length = 0;
10437
10455
  this.patch = 0;
10438
10456
  this.minor = 0;
10439
10457
  this.major++;
10440
- this.inc("pre", identifier);
10458
+ this.inc("pre", identifier, identifierBase);
10441
10459
  break;
10442
10460
  case "preminor":
10443
10461
  this.prerelease.length = 0;
10444
10462
  this.patch = 0;
10445
10463
  this.minor++;
10446
- this.inc("pre", identifier);
10464
+ this.inc("pre", identifier, identifierBase);
10447
10465
  break;
10448
10466
  case "prepatch":
10449
10467
  this.prerelease.length = 0;
10450
- this.inc("patch", identifier);
10451
- this.inc("pre", identifier);
10468
+ this.inc("patch", identifier, identifierBase);
10469
+ this.inc("pre", identifier, identifierBase);
10452
10470
  break;
10453
10471
  case "prerelease":
10454
10472
  if (this.prerelease.length === 0) {
10455
- this.inc("patch", identifier);
10473
+ this.inc("patch", identifier, identifierBase);
10456
10474
  }
10457
- this.inc("pre", identifier);
10475
+ this.inc("pre", identifier, identifierBase);
10458
10476
  break;
10459
10477
  case "major":
10460
10478
  if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
@@ -10493,12 +10511,13 @@ var require_semver = __commonJS({
10493
10511
  }
10494
10512
  }
10495
10513
  if (identifier) {
10514
+ const base = Number(identifierBase) ? 1 : 0;
10496
10515
  if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
10497
10516
  if (isNaN(this.prerelease[1])) {
10498
- this.prerelease = [identifier, 0];
10517
+ this.prerelease = [identifier, base];
10499
10518
  }
10500
10519
  } else {
10501
- this.prerelease = [identifier, 0];
10520
+ this.prerelease = [identifier, base];
10502
10521
  }
10503
10522
  }
10504
10523
  break;
@@ -10518,11 +10537,8 @@ var require_semver = __commonJS({
10518
10537
  var require_parse = __commonJS({
10519
10538
  "node_modules/semver/functions/parse.js"(exports2, module2) {
10520
10539
  var { MAX_LENGTH } = require_constants();
10521
- var { re, t } = require_re();
10522
10540
  var SemVer = require_semver();
10523
- var parseOptions = require_parse_options();
10524
10541
  var parse = (version, options) => {
10525
- options = parseOptions(options);
10526
10542
  if (version instanceof SemVer) {
10527
10543
  return version;
10528
10544
  }
@@ -10532,10 +10548,6 @@ var require_parse = __commonJS({
10532
10548
  if (version.length > MAX_LENGTH) {
10533
10549
  return null;
10534
10550
  }
10535
- const r = options.loose ? re[t.LOOSE] : re[t.FULL];
10536
- if (!r.test(version)) {
10537
- return null;
10538
- }
10539
10551
  try {
10540
10552
  return new SemVer(version, options);
10541
10553
  } catch (er) {
@@ -10574,8 +10586,9 @@ var require_clean = __commonJS({
10574
10586
  var require_inc = __commonJS({
10575
10587
  "node_modules/semver/functions/inc.js"(exports2, module2) {
10576
10588
  var SemVer = require_semver();
10577
- var inc = (version, release, options, identifier) => {
10589
+ var inc = (version, release, options, identifier, identifierBase) => {
10578
10590
  if (typeof options === "string") {
10591
+ identifierBase = identifier;
10579
10592
  identifier = options;
10580
10593
  options = void 0;
10581
10594
  }
@@ -10583,7 +10596,7 @@ var require_inc = __commonJS({
10583
10596
  return new SemVer(
10584
10597
  version instanceof SemVer ? version.version : version,
10585
10598
  options
10586
- ).inc(release, identifier).version;
10599
+ ).inc(release, identifier, identifierBase).version;
10587
10600
  } catch (er) {
10588
10601
  return null;
10589
10602
  }
@@ -10616,19 +10629,32 @@ var require_diff = __commonJS({
10616
10629
  var parse = require_parse();
10617
10630
  var eq = require_eq();
10618
10631
  var diff = (version1, version2) => {
10619
- if (eq(version1, version2)) {
10632
+ const v1 = parse(version1);
10633
+ const v2 = parse(version2);
10634
+ if (eq(v1, v2)) {
10620
10635
  return null;
10621
10636
  } else {
10622
- const v1 = parse(version1);
10623
- const v2 = parse(version2);
10624
10637
  const hasPre = v1.prerelease.length || v2.prerelease.length;
10625
10638
  const prefix = hasPre ? "pre" : "";
10626
10639
  const defaultResult = hasPre ? "prerelease" : "";
10627
- for (const key in v1) {
10628
- if (key === "major" || key === "minor" || key === "patch") {
10629
- if (v1[key] !== v2[key]) {
10630
- return prefix + key;
10631
- }
10640
+ if (v1.major !== v2.major) {
10641
+ return prefix + "major";
10642
+ }
10643
+ if (v1.minor !== v2.minor) {
10644
+ return prefix + "minor";
10645
+ }
10646
+ if (v1.patch !== v2.patch) {
10647
+ return prefix + "patch";
10648
+ }
10649
+ if (!v1.prerelease.length || !v2.prerelease.length) {
10650
+ if (v1.patch) {
10651
+ return "patch";
10652
+ }
10653
+ if (v1.minor) {
10654
+ return "minor";
10655
+ }
10656
+ if (v1.major) {
10657
+ return "major";
10632
10658
  }
10633
10659
  }
10634
10660
  return defaultResult;
@@ -11566,8 +11592,8 @@ var require_range = __commonJS({
11566
11592
  }
11567
11593
  parseRange(range) {
11568
11594
  range = range.trim();
11569
- const memoOpts = Object.keys(this.options).join(",");
11570
- const memoKey = `parseRange:${memoOpts}:${range}`;
11595
+ const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
11596
+ const memoKey = memoOpts + ":" + range;
11571
11597
  const cached = cache.get(memoKey);
11572
11598
  if (cached) {
11573
11599
  return cached;
@@ -11652,6 +11678,7 @@ var require_range = __commonJS({
11652
11678
  tildeTrimReplace,
11653
11679
  caretTrimReplace
11654
11680
  } = require_re();
11681
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
11655
11682
  var isNullSet = (c) => c.value === "<0.0.0-0";
11656
11683
  var isAny = (c) => c.value === "";
11657
11684
  var isSatisfiable = (comparators, options) => {
@@ -11937,12 +11964,6 @@ var require_comparator = __commonJS({
11937
11964
  if (!(comp instanceof Comparator)) {
11938
11965
  throw new TypeError("a Comparator is required");
11939
11966
  }
11940
- if (!options || typeof options !== "object") {
11941
- options = {
11942
- loose: !!options,
11943
- includePrerelease: false
11944
- };
11945
- }
11946
11967
  if (this.operator === "") {
11947
11968
  if (this.value === "") {
11948
11969
  return true;
@@ -11954,13 +11975,29 @@ var require_comparator = __commonJS({
11954
11975
  }
11955
11976
  return new Range(this.value, options).test(comp.semver);
11956
11977
  }
11957
- const sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") && (comp.operator === ">=" || comp.operator === ">");
11958
- const sameDirectionDecreasing = (this.operator === "<=" || this.operator === "<") && (comp.operator === "<=" || comp.operator === "<");
11959
- const sameSemVer = this.semver.version === comp.semver.version;
11960
- const differentDirectionsInclusive = (this.operator === ">=" || this.operator === "<=") && (comp.operator === ">=" || comp.operator === "<=");
11961
- const oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver, options) && (this.operator === ">=" || this.operator === ">") && (comp.operator === "<=" || comp.operator === "<");
11962
- const oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver, options) && (this.operator === "<=" || this.operator === "<") && (comp.operator === ">=" || comp.operator === ">");
11963
- return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
11978
+ options = parseOptions(options);
11979
+ if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
11980
+ return false;
11981
+ }
11982
+ if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
11983
+ return false;
11984
+ }
11985
+ if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
11986
+ return true;
11987
+ }
11988
+ if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
11989
+ return true;
11990
+ }
11991
+ if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
11992
+ return true;
11993
+ }
11994
+ if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
11995
+ return true;
11996
+ }
11997
+ if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
11998
+ return true;
11999
+ }
12000
+ return false;
11964
12001
  }
11965
12002
  };
11966
12003
  module2.exports = Comparator;
@@ -12218,7 +12255,7 @@ var require_intersects = __commonJS({
12218
12255
  var intersects = (r1, r2, options) => {
12219
12256
  r1 = new Range(r1, options);
12220
12257
  r2 = new Range(r2, options);
12221
- return r1.intersects(r2);
12258
+ return r1.intersects(r2, options);
12222
12259
  };
12223
12260
  module2.exports = intersects;
12224
12261
  }
@@ -12303,6 +12340,8 @@ var require_subset = __commonJS({
12303
12340
  }
12304
12341
  return true;
12305
12342
  };
12343
+ var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
12344
+ var minimumVersion = [new Comparator(">=0.0.0")];
12306
12345
  var simpleSubset = (sub, dom, options) => {
12307
12346
  if (sub === dom) {
12308
12347
  return true;
@@ -12311,16 +12350,16 @@ var require_subset = __commonJS({
12311
12350
  if (dom.length === 1 && dom[0].semver === ANY) {
12312
12351
  return true;
12313
12352
  } else if (options.includePrerelease) {
12314
- sub = [new Comparator(">=0.0.0-0")];
12353
+ sub = minimumVersionWithPreRelease;
12315
12354
  } else {
12316
- sub = [new Comparator(">=0.0.0")];
12355
+ sub = minimumVersion;
12317
12356
  }
12318
12357
  }
12319
12358
  if (dom.length === 1 && dom[0].semver === ANY) {
12320
12359
  if (options.includePrerelease) {
12321
12360
  return true;
12322
12361
  } else {
12323
- dom = [new Comparator(">=0.0.0")];
12362
+ dom = minimumVersion;
12324
12363
  }
12325
12364
  }
12326
12365
  const eqSet = /* @__PURE__ */ new Set();
@@ -12520,6 +12559,7 @@ var require_semver2 = __commonJS({
12520
12559
  src: internalRe.src,
12521
12560
  tokens: internalRe.t,
12522
12561
  SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
12562
+ RELEASE_TYPES: constants.RELEASE_TYPES,
12523
12563
  compareIdentifiers: identifiers.compareIdentifiers,
12524
12564
  rcompareIdentifiers: identifiers.rcompareIdentifiers
12525
12565
  };
@@ -22367,11 +22407,11 @@ var require_dist_node31 = __commonJS({
22367
22407
  }
22368
22408
  });
22369
22409
 
22370
- // src/lambdas/github.ts
22410
+ // src/github.ts
22371
22411
  var import_auth_app = __toESM(require_dist_node24());
22372
22412
  var import_rest = __toESM(require_dist_node31());
22373
22413
 
22374
- // src/lambdas/helpers.ts
22414
+ // src/lambda-helpers.ts
22375
22415
  var AWS = __toESM(require("aws-sdk"));
22376
22416
  var sm = new AWS.SecretsManager();
22377
22417
  async function getSecretValue(arn) {
@@ -22388,7 +22428,7 @@ async function getSecretJsonValue(arn) {
22388
22428
  return JSON.parse(await getSecretValue(arn));
22389
22429
  }
22390
22430
 
22391
- // src/lambdas/github.ts
22431
+ // src/github.ts
22392
22432
  function baseUrlFromDomain(domain) {
22393
22433
  if (domain == "github.com") {
22394
22434
  return "https://api.github.com";
@@ -22429,7 +22469,7 @@ async function getOctokit(installationId) {
22429
22469
  };
22430
22470
  }
22431
22471
 
22432
- // src/lambdas/delete-runner.lambda.ts
22472
+ // src/delete-runner.lambda.ts
22433
22473
  async function getRunnerId(octokit, owner, repo, name, idleOnly) {
22434
22474
  let page = 1;
22435
22475
  while (true) {
@@ -22,10 +22,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  mod
23
23
  ));
24
24
 
25
- // src/lambdas/delete-ami.lambda.ts
25
+ // src/image-builders/aws-image-builder/delete-ami.lambda.ts
26
26
  var AWS2 = __toESM(require("aws-sdk"));
27
27
 
28
- // src/lambdas/helpers.ts
28
+ // src/lambda-helpers.ts
29
29
  var AWS = __toESM(require("aws-sdk"));
30
30
  var sm = new AWS.SecretsManager();
31
31
  async function customResourceRespond(event, responseStatus, reason, physicalResourceId, data) {
@@ -62,7 +62,7 @@ async function customResourceRespond(event, responseStatus, reason, physicalReso
62
62
  });
63
63
  }
64
64
 
65
- // src/lambdas/delete-ami.lambda.ts
65
+ // src/image-builders/aws-image-builder/delete-ami.lambda.ts
66
66
  var ec2 = new AWS2.EC2();
67
67
  async function deleteAmis(launchTemplateId, stackName, builderName, deleteAll) {
68
68
  var _a;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+
25
+ // src/image-builders/aws-image-builder/filter-failed-builds.lambda.ts
26
+ var AWS = __toESM(require("aws-sdk"));
27
+ var sns = new AWS.SNS();
28
+ exports.handler = async function(event) {
29
+ console.log(JSON.stringify(event));
30
+ for (const record of event.Records) {
31
+ let message = JSON.parse(record.Sns.Message);
32
+ if (message.state.status === "FAILED") {
33
+ await sns.publish({
34
+ TopicArn: process.env.TARGET_TOPIC_ARN,
35
+ Message: record.Sns.Message
36
+ }).promise();
37
+ }
38
+ }
39
+ };