-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (69 loc) · 2.8 KB
/
build.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
---
name: Look for changed ports and built them
on:
- push
jobs:
list-ports:
runs-on: ubuntu-latest
outputs:
PORTS_TO_BUILD: ${{ steps.conclude-port-to-build.outputs.PORTS_TO_BUILD }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Filter changed paths
uses: dorny/paths-filter@v3
id: filter
with:
list-files: shell
filters: |
ports-to-build:
- "[0-9a-zA-Z]*/**"
ci:
- ".github/workflows/*.yml"
- name: List CI files
if: steps.filter.outputs.ci == 'true'
id: build-all-ports
shell: sh
run: |
echo "steps.filter.outputs.ci_files: '${{ steps.filter.outputs.ci_files }}'"
echo "::notice ::Building all the ports in the repository"
# find ports in the repository and make it a list of one line
# separated by a space.
PORTS_TO_BUILD=`find * -type d -maxdepth 1 -mindepth 1 | tr '\n' ' ' | sed -e 's/ $//'`
# pass the JSON to other jobs
echo "PORTS_TO_BUILD=${PORTS_TO_BUILD}" >> "${GITHUB_OUTPUT}"
cat "${GITHUB_OUTPUT}"
- name: List changed ports
if: steps.filter.outputs.ports-to-build == 'true' && steps.filter.outputs.ci != 'true'
id: list-ports-to-build
shell: sh
run: |
echo "steps.filter.outputs.ports-to-build_files: '${{ steps.filter.outputs.ports-to-build_files }}'"
# find changed ports in the repository and make it a list of one
# line separated by a space.
for F in ${{ steps.filter.outputs.ports-to-build_files }}; do
PORTS_TO_BUILD="${PORTS_TO_BUILD} `echo ${F} | cut -f 1,2 -d '/' | sort -u | grep '/'`"
done
PORTS_TO_BUILD=`echo ${PORTS_TO_BUILD} | sort -u | tr '\n' ' ' | sed -e 's/ $//'`
echo "::notice ::Building ${PORTS_TO_BUILD}"
# pass the JSON to other jobs
echo "PORTS_TO_BUILD=${PORTS_TO_BUILD}" >> "${GITHUB_OUTPUT}"
cat "${GITHUB_OUTPUT}"
- name: Conclude PORTS_TO_BUILD
shell: sh
id: conclude-port-to-build
run: |
PORTS_TO_BUILD=""
if [ ! -z "${{ steps.build-all-ports.outputs.PORTS_TO_BUILD }}" ]; then
PORTS_TO_BUILD="${{ steps.build-all-ports.outputs.PORTS_TO_BUILD }}"
elif [ ! -z "${{ steps.list-ports-to-build.outputs.PORTS_TO_BUILD }}" ]; then
PORTS_TO_BUILD="${{ steps.list-ports-to-build.outputs.PORTS_TO_BUILD }}"
fi
echo "PORTS_TO_BUILD=${PORTS_TO_BUILD}" >> "${GITHUB_OUTPUT}"
cat "${GITHUB_OUTPUT}"
build-ports:
name: Build ports (1st run)
needs: list-ports
uses: ./.github/workflows/poudriere.yml
with:
ports-to-build: ${{ needs.list-ports.outputs.PORTS_TO_BUILD }}