Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 14183ac

Browse files
toast-gearCallum
and
Callum
authored
feat: support single line for app private key (#1368)
* feat: support single line private keys * docs: docs for the new key storage options * docs: use original doc style * style: use single quotes * chore: fmt ts files * docs: use original language more * docs: use the original language more * fix: use correct char code for new line Co-authored-by: Callum <[email protected]>
1 parent 50737a2 commit 14183ac

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ resource "aws_iam_service_linked_role" "spot" {
159159

160160
Next create a second terraform workspace and initiate the module, or adapt one of the [examples](./examples).
161161

162-
Note that `github_app.key_base64` needs to be the base64-encoded `.pem` file, i.e., the output of `base64 app.private-key.pem` (not directly the content of `app.private-key.pem`).
162+
Note that `github_app.key_base64` needs to be a base64-encoded string of the `.pem` file i.e. the output of `base64 app.private-key.pem`. The decoded string can either be a multiline value or a single line value with new lines represented with literal `\n` characters.
163163

164164
```terraform
165165
module "github-runner" {

Diff for: modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ async function createAuth(installationId: number | undefined, ghesApiUrl: string
5151
privateKey: Buffer.from(
5252
await getParameterValue(process.env.PARAMETER_GITHUB_APP_KEY_BASE64_NAME),
5353
'base64',
54-
).toString(),
54+
// replace literal \n characters with new lines to allow the key to be stored as a
55+
// single line variable. This logic should match how the GitHub Terraform provider
56+
// processes private keys to retain compatibility between the projects
57+
)
58+
.toString()
59+
.replace('/[\\n]/g', String.fromCharCode(10)),
5560
};
5661
if (installationId) authOptions = { ...authOptions, installationId };
5762

0 commit comments

Comments
 (0)