-
-
Notifications
You must be signed in to change notification settings - Fork 10
120 lines (107 loc) · 3.7 KB
/
toolchain-sync.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
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
name: Toolchain sync
on:
schedule:
- cron: '0 5 */10 * *'
workflow_dispatch:
jobs:
Prepare:
runs-on: ubuntu-20.04
if: ${{ github.repository_owner == 'armbian' }}
steps:
- name: Cut the job into n chunks
run: |
mkdir -p temp
rsync --exclude '*.current' rsync://rsync.armbian.com/dl/_toolchain/ | awk '{ print $5}' | tail -n +3 > temp/toolchain.chunk
split -d --number=l/20 --additional-suffix=.chunk --suffix-length=2 temp/toolchain.chunk temp/toolchain-
- name: Cache Gradle packages
uses: actions/cache@v2
env:
cache-name: cache-build
with:
path: temp
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.run_id }}
Cache: # short name because GH will expand with the matrix values
needs: [ Prepare ]
runs-on: ubuntu-20.04
timeout-minutes: 480
strategy:
max-parallel: 10
fail-fast: false
matrix:
include:
- part: "00"
- part: "01"
- part: "02"
- part: "03"
- part: "04"
- part: "05"
- part: "06"
- part: "07"
- part: "08"
- part: "09"
- part: "10"
- part: "11"
- part: "12"
- part: "13"
- part: "14"
- part: "15"
- part: "16"
- part: "17"
- part: "18"
- part: "19"
steps:
- name: Install depen
run: sudo apt-get -y install parallel jq axel
- name: Cache Gradle packages
uses: actions/cache@v2
env:
cache-name: cache-build
with:
path: temp
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ github.run_id }}
- name: Download part
run: |
set +e
mkdir -p download
GITURL="${{ github.repository }}"
CHUNK="${{ matrix.part }}"
FILES=$(cat temp/toolchain-${CHUNK}.chunk)
MIRRORS=$(curl -sq http://redirect.armbian.com/mirrors | jq -Mr '.' | grep http | grep -v github | tr -d \"," " | sort | uniq)
for FILE in ${FILES[@]}
do
echo "Checking $FILE"
PARALLEL=$(
for k in ${MIRRORS[@]}
do
echo "${k}_toolchain/${FILE}"
done | parallel --halt now,fail=1 --jobs 32 wget -q --spider --timeout=15 --tries=3 --retry-connrefused {} 2>&1 >/dev/null)
if [[ -n "${PARALLEL}" ]]; then
REMOVE=$(echo $PARALLEL | egrep -o 'https?://[^ ]+/' | sed "s/_toolchain.*//" | sort | uniq)
for l in ${REMOVE[@]}; do
[[ "${DEBUG}" == yes ]] && echo "Removing mirror: $l"
echo "Error,$l,$FILE" >> mirror.log
done
fi
if ! wget -q --spider --timeout=15 --tries=3 --retry-connrefused https://github.com/${GITURL}/releases/download/_toolchain/${FILE} ; then
rsync -av rsync://rsync.armbian.com/dl/_toolchain/${FILE} download/
[[ $(ls -1 download | wc -l) -gt 0 ]] && echo "UPLOAD=true" >> $GITHUB_ENV
fi
done
ls -1 download
- name: Upload artefacts
if: ${{ env.UPLOAD == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: download/*
tag: "_toolchain"
overwrite: true
file_glob: true
body: "This is Armbian file mirror at Github"
- name: Upload logs
uses: actions/upload-artifact@v2
with:
name: logs
path: mirror.log