From c5f4291ff3dd30c7c14d0003a5f73aea253f9d2c Mon Sep 17 00:00:00 2001 From: marcosfad Date: Tue, 29 Mar 2022 22:20:02 +0200 Subject: [PATCH] Add scheduler workflow --- .github/workflows/CI.yml | 10 ++++++++-- .github/workflows/auto-update.yaml | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/auto-update.yaml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a312b06..c755317 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -10,8 +10,14 @@ on: type: string default: '' description: (optional) Choose kernel version to use from T2Linux. Without the "v". + workflow_call: + inputs: + KERNEL_VERSION: + required: true + type: string + env: - KERNEL_VERSION: ${{ github.event.inputs.KERNEL_VERSION }} + KERNEL_VERSION: ${{ github.event.inputs.KERNEL_VERSION || inputs.KERNEL_VERSION }} jobs: build: @@ -26,7 +32,7 @@ jobs: run: | if [ -z "${KERNEL_VERSION}" ]; then echo "KERNEL_VERSION not set, calculating it" - KERNEL_VERSION=$(curl -Ls https://github.com/t2linux/T2-Ubuntu-Kernel/releases/ | grep deb | grep download | grep "${MBP_VERSION}" | cut -d'/' -f6 | head -n1 | cut -d'v' -f2) + KERNEL_VERSION=$(curl -Ls https://github.com/t2linux/T2-Ubuntu-Kernel/releases/ | grep deb | grep download | cut -d'/' -f6 | head -n1 | cut -d'v' -f2) fi echo "::set-output name=build::${KERNEL_VERSION}" diff --git a/.github/workflows/auto-update.yaml b/.github/workflows/auto-update.yaml new file mode 100644 index 0000000..7ba5d3d --- /dev/null +++ b/.github/workflows/auto-update.yaml @@ -0,0 +1,26 @@ +--- +name: CI +# yamllint disable-line rule:truthy +on: + schedule: + - cron: '0 0 * * *' +jobs: + check-update: + runs-on: ubuntu-latest + outputs: + update_available: ${{ steps.variables.outputs.update_available }} + latest_kernel: ${{ steps.variables.outputs.update_available }} + steps: + - name: Configure variables + id: variables + run: | + LATEST_KERNEL_VERSION=$(curl -Ls https://github.com/t2linux/T2-Ubuntu-Kernel/releases/ | grep deb | grep download | grep "${MBP_VERSION}" | cut -d'/' -f6 | head -n1 | cut -d'v' -f2) + curl -Ls https://github.com/marcosfad/mbp-ubuntu/releases | grep zip | grep download | grep "${KERNEL_VERSION}" | cut -d'/' -f6 && REQUIRE_BUILD="false" || REQUIRE_BUILD="true" + echo "::set-output name=update_available::${REQUIRE_BUILD}" + echo "::set-output name=latest_kernel::${LATEST_KERNEL_VERSION}" + trigger-build: + needs: ['check-update'] + uses: ./.github/workflows/CI.yml + if: ${{ needs.check-update.outputs.update_available == true }} + with: + KERNEL_VERSION: ${{ needs.check-update.outputs.latest_kernel }}