Skip to content

Snapshot Build

Snapshot Build #142

Workflow file for this run

# thinRoot Snapshot build
# yamllint disable rule:truthy
---
name: Snapshot Build
on:
schedule:
- cron: '0 0 * * *' # run at 0 AM UTC
workflow_dispatch:
inputs:
skip_build:
description: 'Skip build (for testing workflow)?'
required: true
default: "false"
# default read-only permission
permissions:
contents: read
jobs:
repo-check:
name: Check for Changes
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- id: commit-check
run: echo "has-commits=$(git --no-pager log --pretty='format:%an' --since='24 hours ago' | grep -v github-actions | wc -l)" >> $GITHUB_OUTPUT
outputs:
has-commits: ${{ steps.commit-check.outputs.has-commits }}
build:
permissions:
contents: write # actions/upload-artifact
name: Snapshot build [${{ matrix.platform }}]
if: ${{ github.repository == 'jens-maus/thinRoot' && (github.event_name != 'schedule' || needs.repo-check.outputs.has-commits > 0) }}
runs-on: ubuntu-22.04
needs: repo-check
timeout-minutes: 480
outputs:
build_datetime: ${{ steps.env.outputs.build_datetime }}
build_version: ${{ steps.env.outputs.build_version }}
strategy:
fail-fast: false
matrix:
platform: [intelnuc]
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Install Dependencies
run: |
if ! dpkg-query -l wget bc cpio rsync zip python >/dev/null 2>&1; then
apt update
apt install -y --no-install-recommends wget bc cpio rsync zip python
fi
- name: Setup Environment
id: env
run: |
echo "DATE=$(date +%Y%m%d)" >> $GITHUB_ENV
echo "VERSION=$(date +%Y%m%d)" >> $GITHUB_ENV
echo "GITHUB_SHA7=$(echo ${GITHUB_SHA::7})" >> $GITHUB_ENV
echo "FAKE_BUILD=${{ github.event.inputs.skip_build }}" >> $GITHUB_ENV
JLEVEL=0
if [[ -f /sys/fs/cgroup/cpu.max ]]; then # cgroups v2
CPU_QUOTA=$(cut -d ' ' -f1 /sys/fs/cgroup/cpu.max)
if [[ "${CPU_QUOTA}" != "max" ]]; then
CPU_PERIOD=$(cut -d ' ' -f2 /sys/fs/cgroup/cpu.max)
JLEVEL=$((CPU_QUOTA / CPU_PERIOD + 1))
fi
elif [[ -f /sys/fs/cgroup/cpu/cpu.cfs_quota_us ]]; then # cgroups v1
CPU_QUOTA=$(cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us)
if [[ "${CPU_QUOTA}" != "-1" ]]; then
CPU_PERIOD=$(cat /sys/fs/cgroup/cpu/cpu.cfs_period_us)
JLEVEL=$((CPU_QUOTA / CPU_PERIOD + 1))
fi
fi
echo "JLEVEL=${JLEVEL}" >> $GITHUB_ENV
echo "build_datetime=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT
echo "build_version=$(date +%Y%m%d)" >> $GITHUB_OUTPUT
# - name: remote debug tmate session
# uses: mxschmitt/action-tmate@v1
# if: matrix.platform == 'ova'
# major build step
- name: Build
timeout-minutes: 480
shell: bash
run: |
make distclean
make DATE=${{ env.DATE }} BR2_JLEVEL=${{ env.JLEVEL }} ${{ matrix.platform }}-release
# cleanup
- name: Cleanup
run: |
make distclean
########################
# upload build artifacts
- name: Upload build artifact [intelnuc]
uses: actions/upload-artifact@v4
with:
path: release/thinroot-${{ env.VERSION }}-${{ matrix.platform }}.img*
name: thinroot-${{ env.VERSION }}-${{ env.GITHUB_SHA7 }}-${{ matrix.platform }}.img
continue-on-error: true
cleanup:
permissions:
contents: write # c-hive/gha-remove-artifacts
packages: write # smartsquaregmbh/delete-old-packages
actions: write # c-hive/gha-remove-artifacts
name: Cleanup artifacts/packages
runs-on: ubuntu-22.04
steps:
- name: Remove old artifacts
uses: c-hive/[email protected]
with:
age: '2 months'
skip-tags: true
skip-recent: 15
continue-on-error: true