Skip to content

Allow users to supress CloudWatch Logs #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ The only required input is `project-name`.
When API rate-limiting is hit the back-off time, augmented with jitter, will be
added to the next update interval.
E.g. with update interval of 30 and back-off time of 15, upon hitting the rate-limit
the next interval for the update call will be 30 + random_between(0, 15 _ 2 \*\* 0))
the next interval for the update call will be 30 + random*between(0, 15 * 2 \*\* 0))
seconds and if the rate-limit is hit again the next interval will be
30 + random_between(0, 15 _ 2 \*\* 1) and so on.
30 + random*between(0, 15 * 2 \*\* 1) and so on.

The default value is 15.

1. **hide-cloudwatch-logs** (optional) :
Set to `true` if you do not want CloudWatch Logs to be streamed to GitHub Action.

### Outputs

1. **aws-build-id** : The CodeBuild build ID of the build that the action ran.
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ inputs:
disable-source-override:
description: 'Set to `true` if you want do disable source repo override'
required: false
hide-cloudwatch-logs:
description: 'Set to `true` to prevent the CloudWatch logs from streaming the output to GitHub'
required: false
outputs:
aws-build-id:
description: 'The AWS CodeBuild Build ID for this build.'
Expand Down
18 changes: 11 additions & 7 deletions code-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ function runBuild() {

const inputs = githubInputs();

const config = (({ updateInterval, updateBackOff }) => ({
const config = (({ updateInterval, updateBackOff, hideCloudWatchLogs }) => ({
updateInterval,
updateBackOff,
hideCloudWatchLogs,
}))(inputs);

// Get input options for startBuild
Expand All @@ -44,7 +45,7 @@ async function build(sdk, params, config) {
async function waitForBuildEndTime(
sdk,
{ id, logs },
{ updateInterval, updateBackOff },
{ updateInterval, updateBackOff, hideCloudWatchLogs },
seqEmptyLogs,
totalEvents,
throttleCount,
Expand All @@ -62,13 +63,12 @@ async function waitForBuildEndTime(
const { logGroupName, logStreamName } = logName(cloudWatchLogsArn);

let errObject = false;

// Check the state
const [batch, cloudWatch = {}] = await Promise.all([
codeBuild.batchGetBuilds({ ids: [id] }).promise(),
// The CloudWatchLog _may_ not be set up, only make the call if we have a logGroupName
logGroupName &&
cloudWatchLogs
!hideCloudWatchLogs &&
logGroupName &&
cloudWatchLogs // only make the call if hideCloudWatchLogs is not enabled and a logGroupName exists
.getLogEvents({
logGroupName,
logStreamName,
Expand Down Expand Up @@ -155,7 +155,7 @@ async function waitForBuildEndTime(
return waitForBuildEndTime(
sdk,
current,
{ updateInterval, updateBackOff },
{ updateInterval, updateBackOff, hideCloudWatchLogs },
seqEmptyLogs,
totalEvents,
throttleCount,
Expand Down Expand Up @@ -210,6 +210,9 @@ function githubInputs() {
10
) * 1000;

const hideCloudWatchLogs =
core.getInput("hide-cloudwatch-logs", { required: false }) === "true";

return {
projectName,
owner,
Expand All @@ -223,6 +226,7 @@ function githubInputs() {
updateInterval,
updateBackOff,
disableSourceOverride,
hideCloudWatchLogs,
};
}

Expand Down
Loading