armbian-build/.github/workflows/maintain.yml
2021-12-04 23:42:10 +01:00

94 lines
3.3 KiB
YAML

name: Maintain Runners
on:
workflow_dispatch:
jobs:
Prepare:
name: Prepare runners
runs-on: [self-hosted, Linux, small]
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: Prepare matrix
id: list_dirs
run:
echo ::set-output name=matrix::$(for x in $(seq -w 01 50); do echo $x; done|jq -cnR '[inputs | select(length>0)]' | jq)
Maint:
needs: [ Prepare ]
runs-on: [self-hosted, Linux, small]
if: ${{ github.repository_owner == 'armbian' }}
timeout-minutes: 480
strategy:
fail-fast: false
matrix:
node: ${{fromJson(needs.Prepare.outputs.matrix)}}
steps:
- name: Checkout Armbian build script
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: armbian/build
path: build
ref: nightly
clean: false
- name: Make a test build and cleanup
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
if [[ $(curl -s http://ifconfig.me) == "93.103.15.56" ]]; then
sudo mountpoint -q build/cache/rootfs && sudo fusermount -u build/cache/rootfs || true
sudo mountpoint -q build/cache/toolchain && sudo fusermount -u build/cache/toolchain || true
fi
[[ "$(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
sudo echo '* libraries/restart-without-asking boolean true' | sudo debconf-set-selections
sudo DEBIAN_FRONTEND=noninteractive apt-get -y purge needrestart unattended-upgrades
sudo DEBIAN_FRONTEND=noninteractive apt-get -y update
sudo DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y -y -qq --with-new-pkgs upgrade
sudo DEBIAN_FRONTEND=noninteractive apt-get -y autoremove
[[ -d build/.git ]] && sudo chown -R $USER:$USER build/.git || true
[[ -d build/output/images ]] && sudo rm -rf build/output/images/* || true
cd build
[[ ! -f .ignore_changes ]] && sudo touch .ignore_changes
sudo rm -rf cache/sources
sudo rm -rf output/debs
sudo rm -rf output/debs-beta
sudo shutdown -r 1
Finish:
name: Finish
needs: [Maint]
runs-on: [self-hosted, Linux, small]
if: ${{ github.repository_owner == 'Armbian' }}
steps:
- name: Run script
run: |
echo "Finish"