Files
cache-kernel/.github/workflows/generate.yml
2023-03-05 19:49:14 +01:00

101 lines
4.1 KiB
YAML

name: kernel-simple
on:
schedule:
- cron: '0 */2 * * *' # Scheduled every two hours
workflow_dispatch:
jobs:
prepare:
name: "Make JSON"
if: ${{ github.repository_owner == 'armbian' }}
runs-on: ubuntu-latest
outputs:
matrix: ${{steps.json.outputs.JSON_CONTENT}}
steps:
- name: Checkout Armbian Framework
uses: actions/checkout@v3.3.0
with:
repository: armbian/build
ref: main
fetch-depth: 1
clean: false # true is default. it *will* delete the hosts /dev if mounted inside.
path: build
- name: Checkout Armbian OS
uses: actions/checkout@v3.3.0
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
echo 'JSON_CONTENT<<EOF' >> $GITHUB_OUTPUT
for BRANCH in legacy current edge; do
FILES=$(cat os/targets/*.conf | grep $BRANCH | grep -v "^$" | grep -v "^#" | sed -n $LINE'p' | cut -d " " -f1 | uniq)
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
# runner management
RUNNER=ubuntu-latest
[[ "${ARCH}" == arm64 ]] && RUNNER=aarch64
[[ "${BRANCH}" == current ]] && RUNNER=alfa
[[ "${BRANCH}" == edge ]] && RUNNER=beta
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 ]
strategy:
fail-fast: false # let other jobs try to complete if one fails
matrix:
include: ${{ fromJSON(needs.prepare.outputs.matrix) }}
runs-on: "${{ matrix.runner }}"
name: "${{ matrix.board }} ${{ matrix.branch }} ${{ matrix.runner }}"
env:
BRANCH: "${{ matrix.branch }}"
BOARD: "${{ matrix.board }}"
OCI_TARGET_BASE: "ghcr.io/${{ github.repository }}/" # This is picked up by the Docker launcher automatically
steps:
# Login to ghcr.io, for later uploading rootfs to ghcr.io
- name: Docker Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }} # GitHub username or org
password: ${{ secrets.GITHUB_TOKEN }} # GitHub actions builtin token. repo has to have pkg access.
- name: Checkout build repo
uses: actions/checkout@v3 # We don't need to clone git, really. A wget would suffice for GH-hosted runners. But using clone is better for Igor-hosted runners.
with:
repository: armbian/build #${{ github.repository_owner }}/armbian-build
ref: main
fetch-depth: 1
clean: false # true is default. it *will* delete the hosts /dev if mounted inside.
- 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"