238 lines
7.8 KiB
YAML
238 lines
7.8 KiB
YAML
name: Build beta images
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
# build_chunks:
|
|
# description: 'Build chunks'
|
|
# required: false
|
|
# default: '22'
|
|
workflow_run:
|
|
workflows: ["Build beta & edge"]
|
|
types:
|
|
- completed
|
|
jobs:
|
|
|
|
Prepare:
|
|
|
|
runs-on: [self-hosted, Linux, images]
|
|
if: ${{ github.repository_owner == 'armbian' }}
|
|
outputs:
|
|
matrix: ${{steps.list_dirs.outputs.matrix}}
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
repository: armbian/build
|
|
path: build
|
|
ref: nightly
|
|
clean: false
|
|
|
|
- name: Install SSH key for storage
|
|
|
|
uses: shimataro/ssh-key-action@v2
|
|
with:
|
|
key: ${{ secrets.KEY_TORRENTS }}
|
|
known_hosts: ${{ secrets.KNOWN_HOSTS_UPLOAD }}
|
|
if_key_exists: replace
|
|
|
|
- name: Clean upload folder
|
|
|
|
run: |
|
|
|
|
cd build
|
|
while sudo mountpoint output/images -q
|
|
do
|
|
sudo umount output/images || true
|
|
echo "Trying to unmount ..."
|
|
sleep 10
|
|
done
|
|
sudo apt-get -y -qq install sshfs
|
|
sudo mkdir -p /root/.ssh/
|
|
sudo cp ~/.ssh/known_hosts /root/.ssh/
|
|
sudo rm -rf output/images/*
|
|
sudo mkdir -p output/images
|
|
sudo sshfs upload@users.armbian.com:/images output/images -o IdentityFile=~/.ssh/id_rsa
|
|
sudo find output/images/ -mindepth 1 -type d -exec sudo rm -rf {} \; 2>/dev/null || true
|
|
while sudo mountpoint output/images -q
|
|
do
|
|
sudo umount output/images || true
|
|
echo "Trying to unmount ..."
|
|
sleep 10
|
|
done
|
|
|
|
- name: Cut the job into chunks
|
|
run: |
|
|
|
|
mkdir -p temp
|
|
# clean leftovers
|
|
sudo rm -rf temp/*
|
|
cat build/config/targets-cli-beta.conf build/config/targets-desktop-beta.conf | grep -v "^$" | grep -v "^#" | shuf > temp/split.conf
|
|
split -d --numeric=1 --number=r/22 --additional-suffix=.conf --suffix-length=2 temp/split.conf temp/split-
|
|
echo $CHUNKS
|
|
|
|
- name: Prepare matrix
|
|
id: list_dirs
|
|
run:
|
|
echo ::set-output name=matrix::$(for x in $(seq -w 01 22); do echo $x; done|jq -cnR '[inputs | select(length>0)]' | jq)
|
|
|
|
- name: Cache build configurations
|
|
uses: actions/cache@v2
|
|
env:
|
|
cache-name: cache-build
|
|
with:
|
|
path: temp
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.run_id }}
|
|
|
|
Job: # short name because Github will expand with the matrix values
|
|
|
|
needs: [ Prepare ]
|
|
runs-on: [self-hosted, Linux, images]
|
|
if: ${{ github.repository_owner == 'armbian' }}
|
|
timeout-minutes: 480
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
node: ${{fromJson(needs.Prepare.outputs.matrix)}}
|
|
|
|
steps:
|
|
|
|
- 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: Fix permissions
|
|
run: |
|
|
|
|
# make sure no temporally dirs are mounted from previous runs
|
|
while :
|
|
do
|
|
sudo pkill compile.sh || true
|
|
sudo pkill arm-binfmt-P || true
|
|
sudo pkill aarch64-binfmt-P || true
|
|
sudo pkill pixz || true
|
|
sudo mountpoint -q build/output/images && sudo fusermount -u build/output/images || true
|
|
[[ "$(df | grep "/.tmp" | wc -l)" -eq 0 && $(sudo mountpoint -q build/output/images; echo $?) -eq 1 ]] && sudo rm -rf build/.tmp && break
|
|
echo "Mounted temp directories. Trying to unmount."
|
|
df | grep ".tmp" | awk '{print $6}' | xargs sudo umount 2>/dev/null || true
|
|
sleep 10
|
|
done
|
|
[[ -d build/.git ]] && sudo chown -R $USER:$USER build/.git || true
|
|
[[ -d build/output/images ]] && sudo rm -rf build/output/images/* || true
|
|
|
|
- name: Checkout Armbian build script
|
|
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
repository: armbian/build
|
|
path: build
|
|
ref: nightly
|
|
clean: false
|
|
|
|
- name: Checkout Armbian support scripts
|
|
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
repository: armbian/scripts
|
|
token: ${{ secrets.SCRIPTS_ACCESS_TOKEN }}
|
|
path: scripts
|
|
clean: false
|
|
|
|
- name: Import GPG key
|
|
|
|
uses: crazy-max/ghaction-import-gpg@v3
|
|
with:
|
|
gpg-private-key: ${{ secrets.GPG_KEY1 }}
|
|
passphrase: ${{ secrets.GPG_PASSPHRASE1 }}
|
|
workdir: scripts
|
|
git-user-signingkey: true
|
|
git-commit-gpgsign: true
|
|
|
|
- name: Install SSH key for storage
|
|
|
|
uses: shimataro/ssh-key-action@v2
|
|
with:
|
|
key: ${{ secrets.KEY_TORRENTS }}
|
|
known_hosts: ${{ secrets.KNOWN_HOSTS_UPLOAD }}
|
|
if_key_exists: replace
|
|
|
|
- name: Build beta images
|
|
env:
|
|
GPG_PASS: ${{ secrets.GPG_PASSPHRASE1 }}
|
|
|
|
run: |
|
|
|
|
CHUNK="${{ matrix.node }}"
|
|
cd build
|
|
# use prepared configs
|
|
sudo mkdir -p userpatches
|
|
sudo cp ../scripts/configs/* userpatches/
|
|
# prepare host
|
|
[[ ! -f .ignore_changes ]] && sudo touch .ignore_changes
|
|
./compile.sh KERNEL_ONLY="yes" BOARD="bananapi" BRANCH="current" KERNEL_CONFIGURE="no" USE_TORRENT="yes" REPOSITORY_INSTALL="kernel" 'prepare_host'
|
|
# mount or sync rootfs
|
|
sudo mount cache/rootfs || true
|
|
sudo rsync --size-only --delete -avr rsync://rsync.armbian.com/dl/_rootfs/. cache/rootfs/
|
|
# calculate how many images we can build in parallel
|
|
PARALLEL_BUILDS=$(awk '{printf("%d",$1/5000)}' <<<$(($(LC_ALL=C free -w 2>/dev/null | grep "^Mem" | awk '{print $2}' || LC_ALL=C free | grep "^Mem"| awk '{print $2}')/1024)))
|
|
# mount deploy target
|
|
sudo apt-get -y -qq install sshfs
|
|
sudo mkdir -p /root/.ssh/
|
|
sudo cp ~/.ssh/known_hosts /root/.ssh/
|
|
sudo mkdir -p output/images || true
|
|
sudo sshfs upload@users.armbian.com:/images output/images -o IdentityFile=~/.ssh/id_rsa
|
|
# link build targets
|
|
sudo ln -sf ../../temp/split-${CHUNK}.conf userpatches/targets.conf
|
|
./compile.sh all-new-beta-images MULTITHREAD="${PARALLEL_BUILDS}" GPG_PASS="${GPG_PASS}"
|
|
# umount
|
|
while mountpoint output/images -q
|
|
do
|
|
sudo umount output/images || true
|
|
echo "Trying to unmount ..."
|
|
sleep 10
|
|
done
|
|
cp -R output/debug/Armbian ../temp
|
|
|
|
Deploy:
|
|
|
|
name: Update download infrastructure
|
|
needs: [Job]
|
|
runs-on: [self-hosted, Linux, local]
|
|
if: ${{ github.repository_owner == 'Armbian' }}
|
|
steps:
|
|
- 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: upload artefacts
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: logs
|
|
path: temp/Armbian/
|
|
|
|
- name: Install SSH key for torrent
|
|
uses: shimataro/ssh-key-action@v2
|
|
with:
|
|
key: ${{ secrets.KEY_TORRENTS }}
|
|
name: id_torrent # optional
|
|
known_hosts: ${{ secrets.KNOWN_HOSTS_TORRENTS }}
|
|
if_key_exists: replace
|
|
- name: Create torrents
|
|
run: ssh -T -i ~/.ssh/id_torrent ${{ secrets.USER_TORRENTS }}@${{ secrets.HOST_TORRENTS }}
|