Skip to content

Maintenance: Generate shallow Linux kernel bundles #281

Maintenance: Generate shallow Linux kernel bundles

Maintenance: Generate shallow Linux kernel bundles #281

name: "Maintenance: Generate shallow Linux kernel bundles"
on:
schedule:
- cron: '0 1 * * *' # Scheduled runs every day at 1am UTC
workflow_dispatch:
jobs:
git-trees:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
packages: write
steps:
- name: Free Github Runner
uses: descriptinc/free-disk-space@main # no tagged releases; pinned to default branch
with:
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Docker Login to GitHub Container Registry
uses: docker/login-action@v4
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
uses: actions/checkout@v6
- name: Keep alive
uses: liskin/gh-workflow-keepalive@v1
- name: Test ORAS, Tokens, Logins, etc
env:
TARGET_OCI: "ghcr.io/${{ github.repository }}/kernel-git-oras-validation:latest"
TARGET_FULL_FILE_PATH: "/tmp/test_oras/test.txt"
run: |
mkdir -p "/tmp/test_oras"
date > "${TARGET_FULL_FILE_PATH}"
bash oras_upload.sh
# Restore the most recent worktree cache. The key is unique per run so that the
# matching save step below always writes a fresh cache; restore-keys does a prefix
# match to pull in whatever the latest previous run produced.
- name: Restore git worktree cache
uses: actions/cache/restore@v5
with:
path: /tmp/workdir/kernel/worktree
key: ${{ runner.os }}-kernel-worktree-new-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
${{ runner.os }}-kernel-worktree-new
- name: Prepare git trees, bulk of work, slow
run: |
BASE_WORK_DIR="/tmp/workdir" bash work_kernel_tree.sh
# Save the worktree cache even when the bulk-of-work step above failed (it fails
# intermittently due to network issues). This lets the next run continue from the
# partial progress instead of starting over. Skipped only on cancellation.
- name: Save git worktree cache
if: ${{ !cancelled() }}
uses: actions/cache/save@v5
with:
path: /tmp/workdir/kernel/worktree
key: ${{ runner.os }}-kernel-worktree-new-${{ github.run_id }}-${{ github.run_attempt }}
# Publishing steps below have no explicit "if", so they keep the default success()
# condition: they only run when every previous step (including the bulk of work)
# succeeded. A failed bulk-of-work step therefore skips publishing but still saves cache.
- name: Upload multiple shallow trees to ghcr.io via ORAS
env:
TARGET_OCI_PREFIX: "ghcr.io/${{ github.repository }}/kernel-git-shallow" # :latest
OUTPUT_BASE: "/tmp/workdir/kernel/output_oras"
run: |
for KERNEL_VERSION in $(cat ${OUTPUT_BASE}/shallow_versions.txt); do
echo "::group::Pushing ORAS bundle for shallow ${KERNEL_VERSION}"
echo "version: $KERNEL_VERSION"
export TARGET_OCI="${TARGET_OCI_PREFIX}-${KERNEL_VERSION}:latest"
export TARGET_FULL_FILE_PATH="${OUTPUT_BASE}/linux-shallow-${KERNEL_VERSION}.git.tar"
echo "TARGET_OCI: ${TARGET_OCI}"
echo "TARGET_FULL_FILE_PATH: ${TARGET_FULL_FILE_PATH}"
bash oras_upload.sh
echo "::endgroup::"
done
- name: Upload single complete tree to ghcr.io via ORAS
env:
TARGET_OCI: "ghcr.io/${{ github.repository }}/kernel-git:latest"
TARGET_FULL_FILE_PATH: "/tmp/workdir/kernel/output_oras/linux-complete.git.tar"
run: |
bash oras_upload.sh