From 75299117c1ed964056724d531323a663f3640c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rare=C8=99=20Cosma?= Date: Thu, 26 Sep 2024 09:12:03 +0300 Subject: [PATCH] ci: trigger cache refreshes via cron --- .github/workflows/build.yml | 5 +++-- .github/workflows/cron-cache.yml | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/cron-cache.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9716d6d..82fb51f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,7 @@ on: push: branches: - ci + - "dev/build-yml" - "!main" permissions: @@ -125,7 +126,7 @@ jobs: echo "ASSET_SUM=$ARCHIVE.tar.gz.sha256" >> $GITHUB_ENV - name: Upload release archive - if: github.ref == 'refs/heads/ci' + if: "github.ref == 'refs/heads/ci' && !contains(github.event.head_commit.message, '[cron]')" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: bash @@ -134,7 +135,7 @@ jobs: gh release upload "$version" ${{ env.ASSET }} ${{ env.ASSET_SUM }} promote-release: - if: github.ref == 'refs/heads/ci' + if: "github.ref == 'refs/heads/ci' && !contains(github.event.head_commit.message, '[cron]')" name: promote-release needs: ["build-binaries", "get-version"] runs-on: ubuntu-latest diff --git a/.github/workflows/cron-cache.yml b/.github/workflows/cron-cache.yml new file mode 100644 index 0000000..2ef208f --- /dev/null +++ b/.github/workflows/cron-cache.yml @@ -0,0 +1,32 @@ +name: cron-cache + +on: + push: + branches: + - "dev/cron-cache-yml" + schedule: + - cron: "0 0 */5 * *" + +permissions: + contents: write + +jobs: + create-release: + name: trigger-cron-ci + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.CI_TOKEN }} + - name: Push a special commit to the CI branch + env: + GITHUB_TOKEN: ${{ secrets.CI_TOKEN }} + shell: bash + run: | + ts="$(date "+%F@%T")" + git config --global user.name 'Github Actions' + git config --global user.email 'gh@getbetter.ro' + git branch -D ci-temp || true + git checkout -b ci-temp + git commit --allow-empty --message="[cron] $ts" + git push -u origin ci-temp:ci --force