Cron job to update kernel #1121
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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@v3 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Get the latest driver | |
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 [[ ${latestrelease} = ${latestupstream} ]] | |
then | |
echo "publish=no" >> $GITHUB_ENV | |
exit 0 | |
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@v3 | |
with: | |
ref: LTS | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Get the latest driver | |
id: publish | |
run: | | |
LTS_VER=6.1 | |
latestrelease=$(grep ^KERNEL_VERSION build.sh | head -n1| cut -d = -f2) | |
latestupstream=$(curl -sL https://kernel.org/ | grep ${LTS_VER} | grep tar.xz | cut -d "/" -f 8 | cut -d "\"" -f 1 | cut -d "-" -f 2 | rev | cut -c 8- | rev) | |
if [[ ${latestrelease} = ${latestupstream} ]] | |
then | |
echo "publish=no" >> $GITHUB_ENV | |
exit 0 | |
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: LTS | |