-
Notifications
You must be signed in to change notification settings - Fork 11
154 lines (133 loc) · 5.2 KB
/
Copy pathbuild-kernel-cache.yml
File metadata and controls
154 lines (133 loc) · 5.2 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Build kernel cache
on:
workflow_dispatch:
workflow_call:
inputs:
ACCESS_NAME:
required: false
type: string
default: ${{ github.repository_owner }}
BUILD_BRANCH:
required: false
type: string
default: 'main'
BUILD_RUNNER:
required: false
type: string
default: "ubuntu-latest"
secrets:
ACCESS_TOKEN:
required: true
KEY_TORRENTS:
required: false
KNOWN_HOSTS_UPLOAD:
required: false
jobs:
prepare:
name: "Make JSON"
if: ${{ github.repository_owner == 'armbian' }}
#runs-on: ubuntu-latest
runs-on: fast
outputs:
matrix: ${{steps.json.outputs.JSON_CONTENT}}
steps:
- name: Runner clean
uses: armbian/actions/runner-clean@main
- name: Checkout Armbian Framework
uses: actions/checkout@v4
with:
repository: armbian/build
ref: "${{ inputs.BUILD_BRANCH }}"
fetch-depth: 1
clean: false
path: build
- name: Checkout Armbian OS
uses: actions/checkout@v4
with:
repository: armbian/os
ref: main
fetch-depth: 1
clean: false # true is default. it *will* delete the hosts /dev if mounted inside.
path: os
- name: Build JSON
id: json
run: |
# Make a list of valid pairs from our config
RUNNERS=("alfa" "beta" "gama")
i=0
echo 'JSON_CONTENT<<EOF' >> $GITHUB_OUTPUT
for BRANCH in legacy current midstream edge; do
FILES=$(cat os/targets/*.conf | grep $BRANCH | grep -v "^$" | grep -v "^#" | sed -n $LINE'p' | cut -d " " -f1 | uniq)
if [ -z "${FILES}" ]; then
continue
fi
while IFS= read -r line; do
BOARDFAMILY=$(cat build/config/boards/$line.* | grep BOARDFAMILY | cut -d'"' -f2)
BOARD=$line
source build/config/boards/$line.conf 2> /dev/null || true
source build/config/boards/$line.wip 2> /dev/null || true
source build/config/boards/$line.tvb 2> /dev/null || true
source build/config/sources/families/${BOARDFAMILY}.conf 2> /dev/null || true
# runners are getting random tags from the pool
RUNNER=$(echo ${RUNNERS[$i]})
i=$((i+1))
[[ $i -eq 3 ]] && i=0
echo "${LINUXFAMILY}:${BOARDFAMILY}:${BRANCH}:${line}:${RUNNER}"
done <<< "$FILES"
done | sort | uniq | sort -u -t: -k1,3 | cut -d":" -f3,4,5 | sort | uniq | sed "s/:/ /g" | awk '{ printf "%s%s%s\n", "{\"board\":\""$2"\",", "\"branch\":\""$1"\",", "\"runner\":\""$3"\"}" }' | jq -s >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
kernel:
if: ${{ github.repository_owner == 'armbian' }}
needs: [ prepare ]
name: "${{ matrix.board }} ${{ matrix.branch }} ${{ matrix.runner }}"
runs-on: "${{ matrix.runner }}"
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.prepare.outputs.matrix) }}
env:
BRANCH: "${{ matrix.branch }}"
BOARD: "${{ matrix.board }}"
OCI_TARGET_BASE: "ghcr.io/armbian/cache-kernel/"
steps:
- name: Runner clean
uses: armbian/actions/runner-clean@main
# Login to ghcr.io, for later uploading rootfs to ghcr.io
- name: Docker Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ inputs.ACCESS_NAME }} # GitHub username or org
password: ${{ secrets.ACCESS_TOKEN }} # GitHub actions builtin token. repo has to have pkg access.
- name: Checkout build repo
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/build
ref: "${{ inputs.BUILD_BRANCH }}"
fetch-depth: 1
clean: false
- name: Build Kernel ${{env.BOARD}}:${{env.BRANCH}}
id: kernel
run: |
# BRANCH and BOARD are in the env, but Docker doesn't know that; (sudo has --preserve-env). So we need to pass them as args.
# SHARE_LOG=yes to share logs to pastebin
sudo rm -rf output/debs/* || true
bash ./compile.sh kernel "BRANCH=${{env.BRANCH}}" "BOARD=${{env.BOARD}}" SHARE_LOG=yes CLEAN_LEVEL="alldebs" FORCE_ARTIFACTS_DOWNLOAD="yes"
- name: Install SSH key for storage
env:
KEY_TORRENTS: ${{ secrets.KEY_TORRENTS }}
if: env.KEY_TORRENTS != null
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.KEY_TORRENTS }}
known_hosts: ${{ secrets.KNOWN_HOSTS_UPLOAD }}
if_key_exists: replace
- name: Deploy to server
env:
KEY_TORRENTS: ${{ secrets.KEY_TORRENTS }}
if: env.KEY_TORRENTS != null
run: |
if ! command -v "lftp" > /dev/null 2>&1; then
sudo apt-get -y -qq install lftp
fi
lftp -u upload, -e "set net:timeout 4;set net:max-retries 6;mirror -R --include-glob *.deb --no-empty-dirs --parallel=8 --no-perms output/debs/. debs-beta/ ;bye" sftp://users.armbian.com