From e2d14fb6777d14cf587df51dcb82478d887f9884 Mon Sep 17 00:00:00 2001 From: ajfAfg <56056962+ajfAfg@users.noreply.github.com> Date: Fri, 16 Feb 2024 11:10:54 +0900 Subject: [PATCH] WIP: Add a workflow to create cache periodically --- .../workflows/create-cache-periodically.yml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/create-cache-periodically.yml diff --git a/.github/workflows/create-cache-periodically.yml b/.github/workflows/create-cache-periodically.yml new file mode 100644 index 0000000..a769ec0 --- /dev/null +++ b/.github/workflows/create-cache-periodically.yml @@ -0,0 +1,47 @@ +name: Create cache periodically + +on: + schedule: + # NOTE: + # The cache is valid for 7 days, + # so if we recreate the cache every 6 days, + # the cache will never become invalid. + # (c.f. https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy) + - cron: "0 0 */6 * *" + + workflow_dispatch: + +env: + otp: 26.0 + rebar3: 3.22.1 + +jobs: + test: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + - uses: erlef/setup-beam@v1 + with: + otp-version: ${{ env.otp }} + rebar3-version: ${{ env.rebar3 }} + - uses: actions/cache/restore@v4 + id: cache-restore + with: + path: | + ~/.cache/rebar3 + _build + key: ${{ runner.os }}-otp-${{ env.otp }}-rebar3-${{ env.rebar3 }}-${{ hashFiles('rebar.lock') }} + + # NOTE: Create cache data + - run: rebar3 compile + - run: rebar3 as test compile + - run: rebar3 dialyzer + + - uses: actions/cache/save@v4 + if: always() + with: + path: | + ~/.cache/rebar3 + _build + key: ${{ steps.cache-restore.outputs.cache-primary-key }}