Skip to content

Commit 865f822

Browse files
authored
v1.4.1: Dependency Updates & Test Coverage (#158)
* Update dependencies to the latest versions * 1.4.1 * Fix linting errors * Enabled back typescript-eslint/no-explicit-any eslint rule * Update README.md
1 parent 76542ef commit 865f822

File tree

15 files changed

+32521
-30660
lines changed

15 files changed

+32521
-30660
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: git push origin main --tags
2828

2929
- name: Create Release
30-
uses: actions/create-release@v1
30+
uses: actions/create-release@v4
3131
env:
3232
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3333
with:
@@ -60,4 +60,4 @@ jobs:
6060
"status": "ENABLED"
6161
}
6262
}
63-
}'
63+
}'

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,6 @@ typings/
106106
.idea
107107

108108
# VSCode
109-
.vscode
109+
.vscode
110+
111+
.claude

README.md

Lines changed: 130 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# dark-mechanicum/aws-codebuild
22

3-
[![CodeQL Badge for v1 tag](https://github.com/dark-mechanicum/aws-codebuild/actions/workflows/codeql.yml/badge.svg?tag=v1)](https://github.com/dark-mechanicum/aws-codebuild/actions/workflows/codeql.yml)
4-
[![Validation Badge for v1 tag](https://github.com/dark-mechanicum/aws-codebuild/actions/workflows/validation.yml/badge.svg?tag=v1)](https://github.com/dark-mechanicum/aws-codebuild/actions/workflows/validation.yml)
3+
[![CodeQL Badge](https://github.com/dark-mechanicum/aws-codebuild/actions/workflows/codeql.yml/badge.svg)](https://github.com/dark-mechanicum/aws-codebuild/actions/workflows/codeql.yml)
4+
[![Validation Badge](https://github.com/dark-mechanicum/aws-codebuild/actions/workflows/validation.yml/badge.svg)](https://github.com/dark-mechanicum/aws-codebuild/actions/workflows/validation.yml)
5+
[![Release Version](https://img.shields.io/github/v/release/dark-mechanicum/aws-codebuild)](https://github.com/dark-mechanicum/aws-codebuild/releases)
6+
[![License](https://img.shields.io/github/license/dark-mechanicum/aws-codebuild)](LICENSE)
57

68
Simple, but very powerful GitHub Action to trigger AWS CodeBuild jobs with overrides all parameters and job execution log output.
79

@@ -27,13 +29,14 @@ jobs:
2729
2830
## Description
2931
30-
Under the hood it's using JavaScript AWS SDK for making calls to the AWS API. It means, you can put [any parameters](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CodeBuild.html#startBuild-property) for triggering your AWS CodeBuild Job.
32+
Under the hood it's using AWS SDK for JavaScript (v3) for making calls to the AWS API. It means, you can put [any parameters](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/codebuild/command/StartBuildCommand/) for triggering your AWS CodeBuild Job.
3133
3234
In case if AWS CodeBuild job execution will be failed, it also will fail execution of GitHub Action.
3335
3436
In case if you have enabled AWS CloudWatch logs for AWS CodeBuild job execution, it will put AWS CloudWatch logs output in the GitHub Actions logs output.
3537
3638
## Inputs
39+
3740
```yaml
3841
- name: Executing AWS CodeBuild task
3942
uses: dark-mechanicum/aws-codebuild@v1
@@ -56,28 +59,32 @@ In case if you have enabled AWS CloudWatch logs for AWS CodeBuild job execution,
5659
}'
5760
```
5861
59-
* `projectName` [string] [required] - The name of the CodeBuild build project to start running a build
60-
* `buildStatusInterval` [number] [optional] - Interval in milliseconds to control how often should be checked status of build
61-
* `logsUpdateInterval` [number] [optional] - Interval in milliseconds to control how often should be checked new events in logs stream
62-
* `waitToBuildEnd` [boolean] [optional] - Wait till AWS CodeBuild job will be finished
63-
* `displayBuildLogs` [boolean] [optional] - Display AWS CodeBuild logs output in the GitHub Actions logs output
64-
* `redirectServiceURL` [string] [optional] - In case if that option will be enabled, in the Summary Report, all links will be replaced by the pattern `${redirectServiceURL}${base64_encoded/link}`. That can be useful when some other actions masking credentials like AWS Account ID, Region etc. It will make default generated urls unusable. You can use `https://cloudaws.link/r/` value like example of service usage
65-
* `buildspec` [string] [optional] - Custom parameters to override job parameters in the valid JSON format. Full list of supported parameters you can find in the [CodeBuild.startBuild()](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CodeBuild.html#startBuild-property) documentation
62+
- `projectName` [string] [required] - The name of the CodeBuild build project to start running a build
63+
- `buildStatusInterval` [number] [optional] - Interval in milliseconds to control how often should be checked status of build
64+
- `logsUpdateInterval` [number] [optional] - Interval in milliseconds to control how often should be checked new events in logs stream
65+
- `waitToBuildEnd` [boolean] [optional] - Wait till AWS CodeBuild job will be finished
66+
- `displayBuildLogs` [boolean] [optional] - Display AWS CodeBuild logs output in the GitHub Actions logs output
67+
- `redirectServiceURL` [string] [optional] - In case if that option will be enabled, in the Summary Report, all links will be replaced by the pattern `${redirectServiceURL}${base64_encoded/link}`. That can be useful when some other actions masking credentials like AWS Account ID, Region etc. It will make default generated urls unusable. You can use `https://cloudaws.link/r/` value like example of service usage
68+
- `buildspec` [string] [optional] - Custom parameters to override job parameters in the valid JSON format. Full list of supported parameters you can find in the [StartBuildCommand](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/codebuild/command/StartBuildCommand/) documentation
6669

6770
## AWS Credentials
6871

6972
You can use 2 ways how to put AWS access credentials to this action:
7073

7174
### Environment Variables
75+
7276
[Using environment variables](https://docs.github.com/en/actions/learn-github-actions/environment-variables) (globally or locally):
73-
* **AWS_ACCESS_KEY_ID** - AWS Access Key ID
74-
* **AWS_SECRET_ACCESS_KEY** - AWS Secret Access Key
75-
* **AWS_REGION** - AWS Region where is deployed a CodeBuild Project
77+
78+
- **AWS_ACCESS_KEY_ID** - AWS Access Key ID
79+
- **AWS_SECRET_ACCESS_KEY** - AWS Secret Access Key
80+
- **AWS_REGION** - AWS Region where is deployed a CodeBuild Project
7681

7782
### Using aws-actions/configure-aws-credentials GitHub Action
83+
7884
Setting up credentials files ([AWS Documentation](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html)). Simplest way to do it - use [aws-actions/configure-aws-credentials](https://github.com/aws-actions/configure-aws-credentials) GitHub Action.
7985

8086
Important: if you want a links working correctly in Summary report, remember that action will mask by `***` region, account number and other credentials. If you want make links working, you should assign redirect service to the `redirectServiceURL` action input.
87+
8188
```yaml
8289
- name: Configure AWS Credentials
8390
uses: aws-actions/configure-aws-credentials@v1
@@ -93,9 +100,10 @@ Important: if you want a links working correctly in Summary report, remember tha
93100
```
94101

95102
## Configuration
103+
96104
Unfortunately, [GitHub Actions syntax](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions) do not support complex data types. I've made a decision to use environment variables for building configuration object overrides. It means, you can extend configuration for your AWS CodeBuild Job request with using of environment variables.
97105

98-
Most elegant way to implement overriding of [CodeBuild.startBuild()](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CodeBuild.html#startBuild-property) is using `buildspec` input. The `buildspec` input should contain valid JSON object with values that you are planning to override.
106+
Most elegant way to implement overriding of [StartBuildCommand](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/codebuild/command/StartBuildCommand/) is using `buildspec` input. The `buildspec` input should contain valid JSON object with values that you are planning to override.
99107

100108
```yaml
101109
- name: Executing AWS CodeBuild task
@@ -105,7 +113,7 @@ Most elegant way to implement overriding of [CodeBuild.startBuild()](https://doc
105113
buildspec: '{
106114
"environmentVariablesOverride":[
107115
{ "name":"testEnvVar1", "value":"Testing environment variable", "type": "PLAINTEXT" },
108-
{ "name":"testEnvVar2", "value":"${{ secrets.SOME_SECRET }}", "type": "PLAINTEXT" },
116+
{ "name":"testEnvVar2", "value":"${{ secrets.SOME_SECRET }}", "type": "PLAINTEXT" }
109117
],
110118
"logsConfigOverride": {
111119
"cloudWatchLogs": {
@@ -119,7 +127,7 @@ Most elegant way to implement overriding of [CodeBuild.startBuild()](https://doc
119127

120128
For overriding through environment variables, you need to define environment variable `CODEBUILD__environmentVariablesOverride` and assign complex and valid JSON value to that variable.
121129

122-
To example, if you want to override `environmentVariablesOverride` property (it requires array of objects), you need define `CODEBUILD__environmentVariablesOverride` and assign to it required JSON value
130+
To example, if you want to override `environmentVariablesOverride` property (it requires array of objects), you need define `CODEBUILD__environmentVariablesOverride` and assign to it required JSON value
123131

124132
```yaml
125133
- name: AWS CodeBuild Job
@@ -133,7 +141,8 @@ To example, if you want to override `environmentVariablesOverride` property (it
133141
]'
134142
```
135143

136-
In case, if configuration option do not have a complex type, you can define single environment variable with required to you value.
144+
In case, if configuration option do not have a complex type, you can define single environment variable with required to you value.
145+
137146
```yaml
138147
- name: AWS CodeBuild Job
139148
uses: dark-mechanicum/aws-codebuild@v1
@@ -174,9 +183,7 @@ For example:
174183
{
175184
"Effect": "Allow",
176185
"Action": ["logs:GetLogEvents"],
177-
"Resource": [
178-
"arn:aws:logs:REGION:ACCOUNT_ID:log-group:/aws/codebuild/PROJECT_NAME:*"
179-
]
186+
"Resource": ["arn:aws:logs:REGION:ACCOUNT_ID:log-group:/aws/codebuild/PROJECT_NAME:*"]
180187
}
181188
]
182189
}
@@ -186,15 +193,106 @@ For example:
186193

187194
Current action provides a set of outputs, that you can use in the next steps:
188195

189-
* `id` [string] - The unique ID for the build
190-
* `success` [boolean] - Flag that marks is current AWS CodeBuild job was finished successfully
191-
* `buildNumber` [number] - The number of the build. For each project, the buildNumber of its first build is 1. The buildNumber of each subsequent build is incremented by 1. If a build is deleted, the buildNumber of other builds does not change.
192-
* `timeoutInMinutes` [number] - How long, in minutes, from 5 to 480 (8 hours), for CodeBuild to wait before timing out any related build that did not get marked as completed. The default is 60 minutes
193-
* `initiator` [string] - The AWS entity that started the build
194-
* `buildStatus` [string] - The final status of the build. Valid values include:
195-
* `FAILED`: The build failed.
196-
* `FAULT`: The build faulted.
197-
* `IN_PROGRESS`: The build is still in progress.
198-
* `STOPPED`: The build stopped.
199-
* `SUCCEEDED`: The build succeeded.
200-
* `TIMED_OUT`: The build timed out.
196+
- `id` [string] - The unique ID for the build
197+
- `success` [boolean] - Flag that marks is current AWS CodeBuild job was finished successfully
198+
- `buildNumber` [number] - The number of the build. For each project, the buildNumber of its first build is 1. The buildNumber of each subsequent build is incremented by 1. If a build is deleted, the buildNumber of other builds does not change.
199+
- `timeoutInMinutes` [number] - How long, in minutes, from 5 to 480 (8 hours), for CodeBuild to wait before timing out any related build that did not get marked as completed. The default is 60 minutes
200+
- `initiator` [string] - The AWS entity that started the build
201+
- `buildStatus` [string] - The final status of the build. Valid values include:
202+
- `FAILED`: The build failed.
203+
- `FAULT`: The build faulted.
204+
- `IN_PROGRESS`: The build is still in progress.
205+
- `STOPPED`: The build stopped.
206+
- `SUCCEEDED`: The build succeeded.
207+
- `TIMED_OUT`: The build timed out.
208+
209+
## GitHub Actions Summary
210+
211+
This action automatically generates a detailed [job summary](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary) that appears in the GitHub Actions UI. The summary includes:
212+
213+
- **Build Information**: Job ID, project name, initiator, and execution time
214+
- **AWS Console Link**: Direct link to the CodeBuild job in AWS Console
215+
- **CloudWatch Logs Link**: Link to view logs in AWS CloudWatch (when logs are enabled)
216+
- **Build Configuration**: The buildspec parameters used to start the job
217+
- **Build Phases Table**: Detailed breakdown of each build phase with status and duration
218+
219+
The summary is automatically generated when the build completes and provides a comprehensive overview of the CodeBuild execution without requiring manual log parsing.
220+
221+
### Link Redirection Service
222+
223+
When using the `redirectServiceURL` parameter, all AWS console and CloudWatch links in the summary will be encoded through the redirect service. This is useful when other GitHub Actions mask AWS credentials (account ID, region) making direct links unusable.
224+
225+
Example redirect URL: `https://cloudaws.link/r/`
226+
227+
## Requirements
228+
229+
- **Node.js**: 20 or higher
230+
- **GitHub Actions**: Compatible with all GitHub Actions environments
231+
- **AWS SDK**: Uses AWS SDK for JavaScript v3
232+
233+
## Troubleshooting
234+
235+
### Common Issues
236+
237+
**CodeBuild job fails to start**
238+
239+
- Verify that the `projectName` matches exactly with your AWS CodeBuild project name
240+
- Check that your AWS credentials have `codebuild:StartBuild` permission
241+
- Ensure the CodeBuild project exists in the specified AWS region
242+
243+
**Logs not displaying**
244+
245+
- Verify CloudWatch logs are enabled in your CodeBuild project settings
246+
- Check that your AWS credentials have `logs:GetLogEvents` permission
247+
- Ensure the `displayBuildLogs` input is set to `true` (default)
248+
249+
**Links in summary not working**
250+
251+
- AWS console links may be masked by `aws-actions/configure-aws-credentials`
252+
- Use the `redirectServiceURL` parameter to enable working links
253+
- Example: `redirectServiceURL: 'https://cloudaws.link/r/'`
254+
255+
**Build hangs or times out**
256+
257+
- Check the `buildStatusInterval` setting (default: 5000ms)
258+
- Verify your CodeBuild project timeout settings
259+
- Review CloudWatch logs for build-specific issues
260+
261+
**Permission denied errors**
262+
263+
- Ensure your AWS credentials have all required permissions:
264+
- `codebuild:StartBuild`
265+
- `codebuild:StopBuild`
266+
- `codebuild:BatchGetBuilds`
267+
- `logs:GetLogEvents`
268+
269+
### Getting Help
270+
271+
- Check the [GitHub Issues](https://github.com/dark-mechanicum/aws-codebuild/issues) for similar problems
272+
- Review [AWS CodeBuild documentation](https://docs.aws.amazon.com/codebuild/) for build-specific issues
273+
- Verify your AWS IAM policies match the required permissions above
274+
275+
## Migration Guide
276+
277+
### Upgrading to v1.4.x
278+
279+
- **Node.js**: Minimum version requirement is now Node.js 20
280+
- **AWS SDK**: Migrated from AWS SDK v2 to v3 (no breaking changes for users)
281+
- **GitHub Actions Summary**: Now automatically generated (no configuration required)
282+
- **Version Reference**: Update your workflows to use `@v1.4.1` or `@v1` for latest v1.x.x
283+
284+
### From v1.3.x to v1.4.x
285+
286+
No breaking changes. Simply update the version in your workflow:
287+
288+
```yaml
289+
# Before
290+
uses: dark-mechanicum/[email protected]
291+
292+
# After
293+
uses: dark-mechanicum/aws-codebuild@v1
294+
```
295+
296+
## Changelog
297+
298+
See [Releases](https://github.com/dark-mechanicum/aws-codebuild/releases) for detailed changelog of each version.

0 commit comments

Comments
 (0)