Skip to content

Commit b5dee5f

Browse files
fix: update documentation and run codebuild
Signed-off-by: Scott Schreckengaust <scottschreckengaust@users.noreply.github.com>
1 parent d5045da commit b5dee5f

File tree

2 files changed

+31
-28
lines changed

2 files changed

+31
-28
lines changed

.github/workflows/codebuild.yml

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,36 +77,32 @@ jobs:
7777
version: 0.2
7878
env:
7979
variables:
80-
TEST_ONE: "1"
80+
GH_TOKEN: ${{ github.token }}
8181
phases:
8282
install:
8383
commands:
84-
- echo "install ${TEST_ONE}" | tee --append ./codebuild.out
85-
- dnf install -y lshw || echo "dnf install failed"
84+
- touch ./codebuild.out
85+
- dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo || echo "dnf config-manager"
86+
- dnf install -y 'dnf-command(config-manager)' gh || echo "dnf install failed"
87+
- curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH=$HOME/.local/bin:$PATH || "echo uv failed"
8688
pre_build:
8789
commands:
88-
- echo "pre_build ${TEST_ONE}" | tee --append ./codebuild.out
89-
- echo "=== OS ==="
90-
- cat /etc/os-release
91-
- echo "=== Kernel ==="
92-
- uname -a
93-
- echo "=== CPU ==="
94-
- lscpu
95-
- echo "=== Memory ==="
96-
- free -h
97-
- echo "=== Kisk ==="
98-
- df -h
99-
- echo "=== Block Devices ==="
100-
- lsblk
101-
- echo "=== Hardward Summary ==="
102-
- lshw -short || echo "lshw failed"
90+
- echo "pre_build"
10391
build:
10492
commands:
105-
- echo "build ${TEST_ONE}" | tee --append ./codebuild.out
106-
- ls -alR
93+
- DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')
94+
- CURRENT_BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null || echo "")
95+
- CURRENT_TAG=$(git describe --tags --exact-match 2>/dev/null || echo "")
96+
- IS_RELEASE=$([[ -n "$CURRENT_TAG" ]] && echo "true" || echo "false")
97+
- IS_PRE_RELEASE=$([[ "$CURRENT_BRANCH" == "$DEFAULT_BRANCH" ]] && echo "true" || echo "false")
98+
- IS_PRE_MERGE=$([[ -z "$CURRENT_TAG" && "$CURRENT_BRANCH" != "$DEFAULT_BRANCH" ]] && echo "true" || echo "false")
99+
- if [[ "$IS_RELEASE" == "true" ]]; then echo "This is a release"; fi;
100+
- if [[ "$IS_PRE_RELEASE" == "true" ]]; then echo "This is a pre-release"; fi;
101+
- if [[ "$IS_PRE_MERGE" == "true" ]]; then echo "This is a pre-merge"; fi;
102+
- aws bedrock-runtime invoke-model --model-id 'global.anthropic.claude-opus-4-6-v1' --content-type 'application/json' --accept 'application/json' --body fileb://<(echo '{"anthropic_version":"bedrock-2023-05-31","max_tokens":1024,"messages":[{"role":"user","content":"Hello"}]}') --region 'us-east-1' output.json;
103+
- cat output.json | jq >> ./codebuild.out
107104
post_build:
108105
commands:
109-
- echo "post_build ${TEST_ONE}" | tee --append ./codebuild.out
110106
- echo "Build completed with status $CODEBUILD_BUILD_SUCCEEDING"
111107
- cat ./codebuild.out
112108
artifacts:

docs/DEVELOPERS_GUIDE.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,33 @@ You can run AWS CodeBuild builds locally using the [CodeBuild local agent](https
1111

1212
### Basic Usage
1313

14-
* _optionally edit the `.github/workflows/codebuild.yml`'s `buildspec-override` value_
14+
1. Setup
15+
- Download the local CodeBuild script and make it executable.
16+
- Send the `GH_TOKEN` environmental GitHub Personal Access Token (PAT) into a `./.env` file
1517

1618
```bash
1719
if [ ! -f codebuild_build.sh ]; then
1820
curl -O https://raw.githubusercontent.com/aws/aws-codebuild-docker-images/master/local_builds/codebuild_build.sh && chmod +x codebuild_build.sh;
1921
fi;
22+
echo "GH_TOKEN=${GH_TOKEN:-ghp_notset}" > "./.env";
23+
```
24+
25+
2. Iterate
26+
27+
- _Optionally edit the `buildspec-override` value in the `.github/workflows/codebuild.yml` GitHub workflow_
28+
- Update `./buildspec.yml` based on the workflow contents to a local file
29+
- Run AWS CodeBuild build locally with images based on the machine architecture
2030

21-
# pull the current buildspec.yml out of the workflow
31+
```bash
2232
cat .github/workflows/codebuild.yml \
2333
| uvx yq -r '.jobs.build.steps[] | select(.id == "codebuild") | .with["buildspec-override"]' \
2434
> buildspec.yml
25-
26-
# one-liner local code build with the `buildspec-override` value from the workflow
2735
./codebuild_build.sh \
2836
-i "public.ecr.aws/codebuild/amazonlinux-$([ "$(arch)" = "arm64" ] && echo "aarch64" || echo "x86_64")-standard:$([ "$(arch)" = "arm64" ] && echo "3.0" || echo "5.0")" \
2937
-a "./.codebuild/artifacts/" \
30-
-r "./.codebuild/reports/" \
3138
-l "public.ecr.aws/codebuild/local-builds:$([ "$(arch)" = "arm64" ] && echo "aarch64" || echo "latest")" \
32-
-b "./buildspec.yml" \
33-
-c -p "${AWS_PROFILE:-default}"
39+
-c \
40+
-e "./.env"
3441
```
3542

3643
### All Script Options

0 commit comments

Comments
 (0)