Skip to content

Cron job to update kernel #3753

Cron job to update kernel

Cron job to update kernel #3753

Workflow file for this run

---
name: Cron job to update kernel
on:
schedule:
- cron: '0 */8 * * *'
workflow_dispatch:
jobs:
Mainline:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repo'
uses: actions/checkout@v6
with:
persist-credentials: false
fetch-depth: 0
- name: Check for update
id: publish
run: |
latestrelease=$(grep ^KERNEL_VERSION build.sh | head -n1| cut -d = -f2)
latestupstream=$(curl -sL https://kernel.org/ | grep "latest_button" -A 1 | awk "NR==2" | cut -d "/" -f 8 | cut -d "\"" -f 1 | cut -d "-" -f 2 | rev | cut -c 8- | rev)
if [[ ${latestupstream} = '' ]]
then
echo "Retrying fetching upstream"
latestupstream=$(curl -sL https://kernel.org/ | grep "latest_button" -A 1 | awk "NR==2" | cut -d "/" -f 8 | cut -d "\"" -f 1 | cut -d "-" -f 2 | rev | cut -c 8- | rev)
fi
echo "latestupstream is ${latestupstream}"
echo "current release is ${latestrelease}"
if [[ ${latestrelease} = ${latestupstream} ]]
then
echo "publish=no" >> $GITHUB_ENV
exit 0
elif [[ ${latestupstream} = '' ]]
then
echo "Failed to get upstream ver"
exit 1
else
echo "publish=yes" >> $GITHUB_ENV
sed -i "s/${latestrelease}/${latestupstream}/g" ${{ github.workspace }}/build.sh
sed -i "s/PKGREL=.*/PKGREL=1/g" ${{ github.workspace }}/build.sh
echo "ver=${latestupstream}" >> $GITHUB_ENV
fi
- name: Update the repo
if: env.publish == 'yes'
id: clean
run: |
cd ${{ github.workspace }}
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Update kernel to v${{ env.ver }}" -a
- name: Push changes to the repo
if: env.publish == 'yes'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PAT }}
branch: ${{ github.ref }}
LTS:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repo'
uses: actions/checkout@v6
with:
ref: LTS
persist-credentials: false
fetch-depth: 0
- name: Check for update
id: publish
run: |
LTS_VER=6.18
latestrelease=$(grep ^KERNEL_VERSION build.sh | head -n1| cut -d = -f2)
latestupstream=$(curl -sL https://kernel.org/ | grep -Eo "linux-${LTS_VER}(\.[0-9]+)?\.tar\.xz" | sort -V | tail -n1 | sed -E 's/linux-|\.tar\.xz//g')
if [[ ${latestupstream} = '' ]]
then
echo "Retrying fetching upstream"
latestupstream=$(curl -sL https://kernel.org/ | grep -Eo "linux-${LTS_VER}(\.[0-9]+)?\.tar\.xz" | sort -V | tail -n1 | sed -E 's/linux-|\.tar\.xz//g')
fi
echo "latestupstream is ${latestupstream}"
echo "current release is ${latestrelease}"
if [[ ${latestrelease} = ${latestupstream} ]]
then
echo "publish=no" >> $GITHUB_ENV
exit 0
elif [[ ${latestupstream} = '' ]]
then
echo "Failed to get upstream ver"
exit 1
else
echo "publish=yes" >> $GITHUB_ENV
sed -i "s/${latestrelease}/${latestupstream}/g" ${{ github.workspace }}/build.sh
sed -i "s/PKGREL=.*/PKGREL=1/g" ${{ github.workspace }}/build.sh
echo "ver=${latestupstream}" >> $GITHUB_ENV
fi
- name: Update the repo
if: env.publish == 'yes'
id: clean
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Update kernel to v${{ env.ver }}" -a
- name: Push changes to the repo
if: env.publish == 'yes'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PAT }}
branch: LTS
Mainline_Xanmod:
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- name: 'Checkout Repo'
uses: actions/checkout@v6
with:
ref: Mainline-Xanmod
persist-credentials: false
fetch-depth: 0
- name: Check for update
id: publish
run: |
#brew install gnu-sed
latestrelease=$(grep ^KERNEL_VERSION build.sh | head -n1| cut -d = -f2)
latestupstream=$(git ls-remote --tags --refs https://gitlab.com/xanmod/linux.git | awk -F/ '{print $3}' | sort -V | grep -v -- '-rt' | tail -n1 | cut -d '-' -f 1)
latestpkgrel=$(grep "PKGREL=\d*" build.sh | cut -d = -f2)
latestpkgupstream=$(git ls-remote --tags --refs https://gitlab.com/xanmod/linux.git | awk -F/ '{print $3}' | sort -V | grep -v -- '-rt' | tail -n1 | cut -d '-' -f 2)
echo "latestrelease: ${latestrelease}"
echo "latestupstream: ${latestupstream}"
echo "latestpkgrel: ${latestpkgrel}"
echo "latestpkgupstream: ${latestpkgupstream}"
if [[ ( ${latestrelease} = ${latestupstream} ) && ( ${latestpkgrel} = ${latestpkgupstream} ) ]]
then
echo "publish=no" >> $GITHUB_ENV
exit 0
else
echo "publish=yes" >> $GITHUB_ENV
sed -i "s/${latestrelease}/${latestupstream}/g" ./build.sh
sed -i "s/PKGREL=.*/PKGREL=${latestpkgupstream}/g" ./build.sh
echo "ver=${latestupstream}-${latestpkgupstream}" >> $GITHUB_ENV
fi
- name: Update the repo
if: env.publish == 'yes'
id: clean
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Update kernel to v${{ env.ver }}" -a
- name: Push changes to the repo
if: env.publish == 'yes'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PAT }}
branch: Mainline-Xanmod
LTS_Xanmod:
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- name: 'Checkout Repo'
uses: actions/checkout@v6
with:
ref: LTS-Xanmod
persist-credentials: false
fetch-depth: 0
- name: Check for update
id: publish
run: |
#brew install gnu-sed
LTS_VER=6.18
latestrelease=$(grep ^KERNEL_VERSION build.sh | head -n1| cut -d = -f2)
latestupstream=$(git ls-remote --tags --refs https://gitlab.com/xanmod/linux.git | awk -F/ '{print $3}' | grep "^${LTS_VER}" | sort -V | grep -v -- '-rt' | tail -n1 | cut -d '-' -f 1)
latestpkgrel=$(grep "PKGREL=\d*" build.sh | cut -d = -f2)
latestpkgupstream=$(git ls-remote --tags --refs https://gitlab.com/xanmod/linux.git | awk -F/ '{print $3}' | grep "^${LTS_VER}" | sort -V | grep -v -- '-rt' | tail -n1 | cut -d '-' -f 2)
echo "latestrelease: ${latestrelease}"
echo "latestupstream: ${latestupstream}"
echo "latestpkgrel: ${latestpkgrel}"
echo "latestpkgupstream: ${latestpkgupstream}"
if [[ ( ${latestrelease} = ${latestupstream} ) && ( ${latestpkgrel} = ${latestpkgupstream} ) ]]
then
echo "publish=no" >> $GITHUB_ENV
exit 0
else
echo "publish=yes" >> $GITHUB_ENV
sed -i "s/${latestrelease}/${latestupstream}/g" ./build.sh
sed -i "s/PKGREL=.*/PKGREL=${latestpkgupstream}/g" ./build.sh
echo "ver=${latestupstream}-${latestpkgupstream}" >> $GITHUB_ENV
fi
- name: Update the repo
if: env.publish == 'yes'
id: clean
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Update kernel to v${{ env.ver }}" -a
- name: Push changes to the repo
if: env.publish == 'yes'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PAT }}
branch: LTS-Xanmod