Skip to content

sync remote patches #710

sync remote patches

sync remote patches #710

name: sync remote patches
on:
schedule:
- cron: '17 */12 * * *' # “At minute 17 past every 12th hour.”
workflow_dispatch:
jobs:
sync-remote-patch:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1
matrix:
include:
- description: BORE patch from upstream
type: patches-in-git-repo
repo_link: https://github.com/firelzrd/bore-scheduler.git
patch_file_regex: .*/patches/(stable|legacy)/linux-$kver-bore/0001-linux.*.patch
copy_as: 0001-bore.patch
- description: Gentoo Kconfig patch
type: direct-link
src_file_link: https://dev.gentoo.org/~mpagano/genpatches/trunk/$kver/4567_distro-Gentoo-Kconfig.patch
copy_as: 0013-gentoo-kconfig.patch
- description: Gentoo Print loaded firmware patch
type: direct-link
src_file_link: https://dev.gentoo.org/~mpagano/genpatches/trunk/$kver/3000_Support-printing-firmware-info.patch
copy_as: 0013-gentoo-print-loaded-firmware.patch
- description: linux-hardened patches
type: github-release
repo: anthraxx/linux-hardened
tag_regex: 'v$kver.'
asset_name: 'linux-hardened-$tag.patch'
copy_as: 0012-linux-hardened.patch
steps:
- name: Checkout linux-tkg
uses: actions/checkout@v4
- name: Sync direct-link patches
if: matrix.type == 'direct-link'
id: direct-link-sync
run: |
set -e
cd linux-tkg-patches
for kver in *
do
[[ ! -d "$kver" ]] && continue
file_link=$(eval "echo ${{ matrix.src_file_link }}")
echo "Checking link $file_link"
if wget $file_link -O $kver/"${{ matrix.copy_as }}".new &> /dev/null
then
echo "Link exists"
echo "Overwriting linux-tkg-patches/$kver/${{ matrix.copy_as }} with remote file"
mv -f $kver/"${{ matrix.copy_as }}".new $kver/"${{ matrix.copy_as }}"
git add -N $kver/"${{ matrix.copy_as }}"
else
echo "Link doesn't exist"
rm $kver/"${{ matrix.copy_as }}".new
fi
done
- name: Sync github-release patches
if: matrix.type == 'github-release'
id: gihtub-release-sync
env:
GH_TOKEN: ${{ github.token }}
run: |
set -e
all_tags=$(gh release list -R ${{ matrix.repo }} -L 100 | awk '{print $1}' )
cd linux-tkg-patches
for kver in *
do
[[ ! -d "$kver" ]] && continue
tag_regex=$(eval "echo ${{ matrix.tag_regex }}")
tag=$(echo "$all_tags" | grep -F "$tag_regex" | head -n1)
asset_name=$(eval "echo ${{ matrix.asset_name }}")
file_link="https://github.com/${{ matrix.repo }}/releases/download/$tag/$asset_name"
echo "Checking link $file_link"
if wget $file_link -O $kver/"${{ matrix.copy_as }}".new &> /dev/null
then
echo "Link exists"
echo "Overwriting linux-tkg-patches/$kver/${{ matrix.copy_as }} with remote file"
mv -f $kver/"${{ matrix.copy_as }}".new $kver/"${{ matrix.copy_as }}"
git add -N $kver/"${{ matrix.copy_as }}"
else
echo "Link doesn't exist"
rm $kver/"${{ matrix.copy_as }}".new
fi
done
- name: Sync git-repo patches
if: matrix.type == 'patches-in-git-repo'
id: patches-in-git-repo-sync
env:
GH_TOKEN: ${{ github.token }}
run: |
set -e
_workspace=$(realpath .)
git clone ${{ matrix.repo_link }} --depth=1 remote-patch-repo
cd linux-tkg-patches
for kver in *
do
[[ ! -d "$kver" ]] && continue
echo "Looking for patches for $kver"
patches=($(find "$_workspace"/remote-patch-repo -regextype posix-extended -regex "${{ matrix.patch_file_regex }}" | sort))
if [[ "${#patches[@]}" != 0 ]]
then
echo "Found ${patches[-1]}"
cp "${patches[-1]}" $kver/${{ matrix.copy_as }}
else
echo "Found none"
fi
done
rm -rf remote-patch-repo
- name: Check for changes
id: change-check
run: |
if git diff --exit-code . > /dev/null
then
echo "patches-updated=0" >> $GITHUB_OUTPUT
else
echo "patches-updated=1" >> $GITHUB_OUTPUT
fi
- name: Push changes
if: steps.change-check.outputs.patches-updated == '1'
run: |
git config --global user.name 'Frogminer'
git config --global user.email 'frogminer@miner.frog'
cd linux-tkg-patches
git add .
git commit -m "Update ${{ matrix.description }}"
git pull --rebase
git push