Skip to content

Commit 111b9d8

Browse files
committed
add code build managed pr build
1 parent 3d919db commit 111b9d8

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: CodeBuild PR Build
2+
3+
on:
4+
workflow_dispatch: {}
5+
merge_group: {}
6+
push:
7+
branches:
8+
- main
9+
- v2-release
10+
pull_request:
11+
branches:
12+
- main
13+
- v2-release
14+
15+
# For every PR, cancel any previous builds in progress
16+
# ... but for all other builds we keep them running
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.pull_request.number || github.run_id }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
build:
23+
if: github.repository != 'aws/aws-cdk'
24+
runs-on: codebuild-aws-cdk-github-actions-runner-${{ github.run_id }}-${{ github.run_attempt }}
25+
26+
env:
27+
PR_BUILD: true
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: "18"
37+
cache: "yarn"
38+
39+
- name: Set up Docker
40+
uses: docker/setup-buildx-action@v3
41+
42+
- name: Load Docker images
43+
id: docker-cache
44+
uses: actions/cache/restore@v4
45+
with:
46+
path: |
47+
~/.docker-images.tar
48+
key: docker-cache-${{ runner.os }}
49+
50+
- name: Restore Docker images
51+
if: ${{ steps.docker-cache.outputs.cache-hit }}
52+
run: docker image load --input ~/.docker-images.tar
53+
54+
- name: Cache build artifacts
55+
uses: actions/cache@v4
56+
with:
57+
path: |
58+
~/.s3buildcache
59+
key: s3buildcache-${{ runner.os }}
60+
61+
- name: Configure system settings
62+
run: |
63+
(command -v sysctl || sudo apt-get update && sudo apt-get install -y procps) && \
64+
sudo sysctl -w vm.max_map_count=2251954
65+
66+
- name: Build
67+
run: /bin/bash ./build.sh --ci
68+
69+
- name: Run Rosetta
70+
run: /bin/bash ./scripts/run-rosetta.sh
71+
72+
- name: Check for uncommitted changes
73+
run: git diff-index --exit-code --ignore-space-at-eol --stat HEAD
74+
75+
- name: Export Docker images
76+
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
77+
run: docker image save --output ~/.docker-images.tar $(docker image list --format '{{ if ne .Repository "<none>" }}{{ .Repository }}{{ if ne .Tag "<none>" }}:{{ .Tag }}{{ end }}{{ else }}{{ .ID }}{{ end }}')
78+
79+
- name: Cache Docker images
80+
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
81+
uses: actions/cache/save@v4
82+
with:
83+
path: |
84+
~/.docker-images.tar
85+
key: docker-cache-${{ runner.os }}

0 commit comments

Comments
 (0)