-
Notifications
You must be signed in to change notification settings - Fork 2.2k
93 lines (77 loc) · 3.24 KB
/
build-pull-request.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Build Pull Request
on: [pull_request]
jobs:
check_file_changes:
name: Check file changes
outputs:
has_csharp_changes: ${{ steps.check_files.outputs.has_csharp_changes }}
has_go_changes: ${{ steps.check_files.outputs.has_go_changes }}
has_java_changes: ${{ steps.check_files.outputs.has_java_changes }}
has_python_changes: ${{ steps.check_files.outputs.has_python_changes }}
has_typescript_changes: ${{ steps.check_files.outputs.has_typescript_changes }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Check files
id: check_files
run: |
echo "========== categorization of changed files =========="
for file in $(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }})
do
echo -n "$file => "
case $file in
csharp/*)
echo "C#"
echo "::set-output name=has_csharp_changes::true"
;;
go/*)
echo "Go"
echo "::set-output name=has_go_changes::true"
;;
java/*)
echo "Java"
echo "::set-output name=has_java_changes::true"
;;
python/*)
echo "Python"
echo "::set-output name=has_python_changes::true"
;;
typescript/*)
echo "TypeScript"
echo "::set-output name=has_typescript_changes::true"
;;
*)
echo "<unmatched>"
;;
esac
done
build:
needs: check_file_changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Runs docker builds with JSII superchain
run: |
HAS_CSHARP_CHANGES="${{needs.check_file_changes.outputs.has_csharp_changes}}"
HAS_GO_CHANGES="${{needs.check_file_changes.outputs.has_go_changes}}"
HAS_JAVA_CHANGES="${{needs.check_file_changes.outputs.has_java_changes}}"
HAS_PYTHON_CHANGES="${{needs.check_file_changes.outputs.has_python_changes}}"
HAS_TYPESCRIPT_CHANGES="${{needs.check_file_changes.outputs.has_typescript_changes}}"
if [ "${HAS_CSHARP_CHANGES}" == "true" ]; then
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-csharp.sh"
fi
if [ "${HAS_GO_CHANGES}" == "true" ]; then
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-go.sh"
fi
if [ "${HAS_JAVA_CHANGES}" == "true" ]; then
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-java.sh"
fi
if [ "${HAS_PYTHON_CHANGES}" == "true" ]; then
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-python.sh"
fi
if [ "${HAS_TYPESCRIPT_CHANGES}" == "true" ]; then
docker run --rm --net=host -t -v $PWD:$PWD -w $PWD jsii/superchain:1-buster-slim-node18 /bin/bash -c "scripts/build-typescript.sh"
fi