Skip to content

Commit

Permalink
Merge pull request #126 from aws-actions/fix-log
Browse files Browse the repository at this point in the history
Allow users to suppress CloudWatch Logs
  • Loading branch information
taoyong-ty authored Feb 18, 2023
2 parents 80cf72c + 7aff79d commit 39cc659
Show file tree
Hide file tree
Showing 5 changed files with 69,391 additions and 62,245 deletions.
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

0 comments on commit 39cc659

Please sign in to comment.