Skip to content

Commit 3246e9e

Browse files
authored
Merge pull request #1398 from philips-labs/develop
release
2 parents 8808014 + 4617261 commit 3246e9e

File tree

14 files changed

+726
-663
lines changed

14 files changed

+726
-663
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191

9292
steps:
9393
- name: Generate provenance for release
94-
uses: philips-labs/[email protected].0
94+
uses: philips-labs/[email protected].2
9595
with:
9696
artifact_path: release-assets
9797
output_path: 'build.provenance'

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ This [Terraform](https://www.terraform.io/) module creates the required infrastr
2424
- [Providers](#providers)
2525
- [Modules](#modules)
2626
- [Resources](#resources)
27-
- [Modules](#modules-1)
28-
- [Resources](#resources-1)
2927
- [Inputs](#inputs)
3028
- [Outputs](#outputs)
3129
- [Contribution](#contribution)
@@ -159,7 +157,7 @@ resource "aws_iam_service_linked_role" "spot" {
159157

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

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`).
160+
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.
163161

164162
```terraform
165163
module "github-runner" {

modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@typescript-eslint/eslint-plugin": "^4.33.0",
2323
"@typescript-eslint/parser": "^4.33.0",
2424
"@vercel/ncc": "^0.31.1",
25-
"aws-sdk": "^2.1019.0",
25+
"aws-sdk": "^2.1023.0",
2626
"eslint": "^7.32.0",
2727
"eslint-plugin-prettier": "4.0.0",
2828
"jest": "^27.3.1",

modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,10 +1027,10 @@ asynckit@^0.4.0:
10271027
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
10281028
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=
10291029

1030-
aws-sdk@^2.1019.0:
1031-
version "2.1019.0"
1032-
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1019.0.tgz#3859bcadcabc02aa7c663ee3aca42eb1345c8251"
1033-
integrity sha512-mnL9CROb3JHdAIbwjy0yr7Lj76KVA8+LyDFexIq/J/YtjbqdfEsb/KdeQIGEBCdlOqUrcJmeD0GcklZ4ve6fnQ==
1030+
aws-sdk@^2.1023.0:
1031+
version "2.1023.0"
1032+
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1023.0.tgz#0de16e4e8878ccec4fcd0146322dcf94fdbe09ba"
1033+
integrity sha512-RAI8sUfK+00yL9i3xz5kbM3+t/0mjjnKhKyauXAlJN4seDYtIX5+BqMghpkZwvLBdi6idXIuz+FHWETHZccyuA==
10341034
dependencies:
10351035
buffer "4.9.2"
10361036
events "1.1.1"

modules/runners/lambdas/runners/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@
2727
"jest": "27.3.1",
2828
"jest-mock-extended": "^2.0.1",
2929
"moment-timezone": "^0.5.33",
30-
"nock": "^13.1.4",
30+
"nock": "^13.2.0",
3131
"prettier": "2.4.1",
3232
"ts-jest": "^27.0.7",
3333
"ts-node": "^10.4.0",
3434
"ts-node-dev": "^1.1.6"
3535
},
3636
"dependencies": {
37-
"@aws-sdk/client-ssm": "^3.39.0",
37+
"@aws-sdk/client-ssm": "^3.40.0",
3838
"@octokit/auth-app": "3.6.0",
3939
"@octokit/rest": "^18.12.0",
4040
"@octokit/types": "^6.34.0",
4141
"@types/aws-lambda": "^8.10.85",
4242
"@types/express": "^4.17.11",
4343
"@types/node": "^16.11.6",
44-
"aws-sdk": "^2.1019.0",
44+
"aws-sdk": "^2.1024.0",
4545
"cron-parser": "^4.1.0",
4646
"tslog": "^3.2.2",
4747
"typescript": "^4.4.4"

modules/runners/lambdas/runners/src/scale-runners/gh-auth.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,34 @@ describe('Test createGithubAppAuth', () => {
7171
process.env.ENVIRONMENT = ENVIRONMENT;
7272
});
7373

74+
test('Creates auth object with line breaks in SSH key.', async () => {
75+
// Arrange
76+
const authOptions = {
77+
appId: parseInt(GITHUB_APP_ID),
78+
privateKey: `${decryptedValue}
79+
${decryptedValue}`,
80+
installationId,
81+
};
82+
83+
const b64PrivateKeyWithLineBreaks = Buffer.from(decryptedValue + '\n' + decryptedValue, 'binary').toString(
84+
'base64',
85+
);
86+
mockedGet.mockResolvedValueOnce(GITHUB_APP_ID).mockResolvedValueOnce(b64PrivateKeyWithLineBreaks);
87+
88+
const mockedAuth = jest.fn();
89+
mockedAuth.mockResolvedValue({ token });
90+
mockedCreatAppAuth.mockImplementation(() => {
91+
return mockedAuth;
92+
});
93+
94+
// Act
95+
await createGithubAppAuth(installationId);
96+
97+
// Assert
98+
expect(mockedCreatAppAuth).toBeCalledTimes(1);
99+
expect(mockedCreatAppAuth).toBeCalledWith(authOptions);
100+
});
101+
74102
test('Creates auth object for public GitHub', async () => {
75103
// Arrange
76104
const authOptions = {

modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts

Lines changed: 6 additions & 1 deletion
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)