Skip to content

Commit

Permalink
Merge pull request #35 from brave-intl/private-repo-access
Browse files Browse the repository at this point in the history
Add GP SSH private key input
  • Loading branch information
tarikdem authored Jun 3, 2024
2 parents 00750bf + 83b735c commit 6deb4a2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 20 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ inputs:
disable-github-env-vars:
description: 'Set to `true` if you want do disable github environment variables in codebuild'
required: false
gp-ssh-private-key-b64:
description: 'Base64 encoded deploy key for private repo access - used for fetching private dependencies'
required: false
outputs:
aws-build-id:
description: 'The AWS CodeBuild Build ID for this build.'
Expand Down
34 changes: 24 additions & 10 deletions code-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ async function build(sdk, params, config) {
branch: params.branch,
sourceVersion: params.sourceVersion,
reproducible: params.reproducible,
gpSshPrivateKeyB64: params.gpSshPrivateKeyB64,
imageTag,
}),
})
Expand Down Expand Up @@ -100,15 +101,15 @@ async function waitForBuildEndTime(
})
),
!hideCloudWatchLogs &&
logGroupName &&
cloudWatchLogs.send(
new GetLogEventsCommand({
logGroupName,
logStreamName,
startFromHead,
nextToken,
})
),
logGroupName &&
cloudWatchLogs.send(
new GetLogEventsCommand({
logGroupName,
logStreamName,
startFromHead,
nextToken,
})
),
]).catch((err) => {
errObject = err;
/* Returning [] here so that the assignment above
Expand Down Expand Up @@ -241,6 +242,10 @@ function githubInputs() {
const disableGithubEnvVars =
core.getInput("disable-github-env-vars", { required: false }) === "true";

const gpSshPrivateKeyB64 = core.getInput("gp-ssh-private-key-b64", {
required: false,
});

return {
owner,
repo,
Expand All @@ -251,11 +256,19 @@ function githubInputs() {
updateBackOff,
hideCloudWatchLogs,
disableGithubEnvVars,
gpSshPrivateKeyB64,
};
}

function inputs2Parameters(inputs) {
const { owner, repo, branch, sourceVersion, reproducible } = inputs;
const {
owner,
repo,
branch,
sourceVersion,
reproducible,
gpSshPrivateKeyB64,
} = inputs;

// The idempotencyToken is intentionally not set.
// This way the GitHub events can manage the builds.
Expand All @@ -265,6 +278,7 @@ function inputs2Parameters(inputs) {
branch,
sourceVersion,
reproducible,
gpSshPrivateKeyB64,
};
}

Expand Down
34 changes: 24 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ async function build(sdk, params, config) {
branch: params.branch,
sourceVersion: params.sourceVersion,
reproducible: params.reproducible,
gpSshPrivateKeyB64: params.gpSshPrivateKeyB64,
imageTag,
}),
})
Expand Down Expand Up @@ -106,15 +107,15 @@ async function waitForBuildEndTime(
})
),
!hideCloudWatchLogs &&
logGroupName &&
cloudWatchLogs.send(
new GetLogEventsCommand({
logGroupName,
logStreamName,
startFromHead,
nextToken,
})
),
logGroupName &&
cloudWatchLogs.send(
new GetLogEventsCommand({
logGroupName,
logStreamName,
startFromHead,
nextToken,
})
),
]).catch((err) => {
errObject = err;
/* Returning [] here so that the assignment above
Expand Down Expand Up @@ -247,6 +248,10 @@ function githubInputs() {
const disableGithubEnvVars =
core.getInput("disable-github-env-vars", { required: false }) === "true";

const gpSshPrivateKeyB64 = core.getInput("gp-ssh-private-key-b64", {
required: false,
});

return {
owner,
repo,
Expand All @@ -257,11 +262,19 @@ function githubInputs() {
updateBackOff,
hideCloudWatchLogs,
disableGithubEnvVars,
gpSshPrivateKeyB64,
};
}

function inputs2Parameters(inputs) {
const { owner, repo, branch, sourceVersion, reproducible } = inputs;
const {
owner,
repo,
branch,
sourceVersion,
reproducible,
gpSshPrivateKeyB64,
} = inputs;

// The idempotencyToken is intentionally not set.
// This way the GitHub events can manage the builds.
Expand All @@ -271,6 +284,7 @@ function inputs2Parameters(inputs) {
branch,
sourceVersion,
reproducible,
gpSshPrivateKeyB64,
};
}

Expand Down

0 comments on commit 6deb4a2

Please sign in to comment.