Skip to content

Sync Linux upstream refs #2

Sync Linux upstream refs

Sync Linux upstream refs #2

name: Sync Linux upstream refs
on:
workflow_dispatch:
schedule:
- cron: "17 */6 * * *"
permissions:
contents: write
concurrency:
group: sync-linux-upstream
cancel-in-progress: false
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout fork
uses: actions/checkout@v4
with:
fetch-depth: 1
persist-credentials: true
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Determine latest Linux releases
id: versions
run: |
set -euo pipefail
releases="$(curl -fsSL https://www.kernel.org/releases.json)"
mainline="$(jq -r 'first(.releases[] | select(.moniker == "mainline" and (.iseol == false)) | .version)' <<<"$releases")"
stable="$(jq -r 'first(.releases[] | select(.moniker == "stable" and (.iseol == false)) | .version)' <<<"$releases")"
test -n "$mainline"
test -n "$stable"
{
echo "mainline_tag=v$mainline"
echo "stable_tag=v$stable"
echo "stable_branch=linux-${stable%.*}.y"
} >> "$GITHUB_OUTPUT"
- name: Fetch upstream refs
run: |
set -euo pipefail
git remote add torvalds https://github.com/torvalds/linux.git
git remote add stable https://github.com/gregkh/linux.git
git fetch --depth=1 torvalds \
refs/heads/master:refs/remotes/torvalds/master
git fetch --depth=1 torvalds \
refs/tags/${{ steps.versions.outputs.mainline_tag }}:refs/tags/${{ steps.versions.outputs.mainline_tag }}
git fetch --depth=1 stable \
refs/heads/${{ steps.versions.outputs.stable_branch }}:refs/remotes/stable/${{ steps.versions.outputs.stable_branch }}
git fetch --depth=1 stable \
refs/tags/${{ steps.versions.outputs.stable_tag }}:refs/tags/${{ steps.versions.outputs.stable_tag }}
- name: Push mirror refs to fork
run: |
set -euo pipefail
git push --force-with-lease origin \
refs/remotes/torvalds/master:refs/heads/mainline
git push --force-with-lease origin \
refs/remotes/stable/${{ steps.versions.outputs.stable_branch }}:refs/heads/stable/${{ steps.versions.outputs.stable_branch }}
git push origin \
refs/tags/${{ steps.versions.outputs.mainline_tag }}:refs/tags/${{ steps.versions.outputs.mainline_tag }}
git push origin \
refs/tags/${{ steps.versions.outputs.stable_tag }}:refs/tags/${{ steps.versions.outputs.stable_tag }}