Bump github action versions (#95) #141
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: Refresh Dev Cache ♻️ | |
# We need this workflow to ensure that MIX_ENV=dev caches are available when | |
# the CI workflow runs for a tagged build. This is due to a combination of | |
# several factors, so it's worthy of a wordy explanation. | |
# | |
# The actions/cache step stores the caches per-branch and if the cache key misses | |
# for a branch, it will try to find a cache from its default branch (main). | |
# So, when we run CI for a new branch or a new tag, there will be a cache miss | |
# and the cache step will try to find a cache from the main branch. | |
# The problem is, we only build with MIX_ENV=dev when a tag is pushed. That | |
# means our main CI workflow never builds a dev cache in the main branch. | |
# When we push a new tag for a release, the actions/cache step will always miss | |
# and then check main for a dev cache. We need this workflow to ensure that | |
# it will find a recent dev cache. | |
# | |
# Many of the steps are duplicated between this workflow and the | |
# publish-hex-package job in the Actions CI workflow. | |
on: | |
push: | |
branches: | |
- main | |
# Would like to run this as a scheduled workflow, but that is not currently | |
# supported by the actions/cache action. | |
env: | |
CUATRO_HEX_KEY: ${{ secrets.CUATRO_HEX_KEY }} | |
jobs: | |
refresh-dev-cache: | |
name: Refresh Docs Cache | |
runs-on: ubuntu-20.04 | |
env: | |
MIX_ENV: dev | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Determine the elixir version | |
run: echo "ELIXIR_VERSION=$(grep -h elixir .tool-versions | awk '{ print $2 }' | awk -F - '{print $1}')" >> $GITHUB_ENV | |
- name: Determine the otp version | |
run: echo "OTP_VERSION=$(grep -h erlang .tool-versions | awk '{ print $2 }')" >> $GITHUB_ENV | |
- name: Setup Elixir and Erlang versions | |
uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ env.OTP_VERSION }} | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
- name: Restore the deps cache | |
uses: actions/cache@v4 | |
id: deps-cache | |
with: | |
path: deps | |
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps- | |
- name: Restore the _build cache | |
uses: actions/cache@v4 | |
id: build-cache | |
with: | |
path: _build | |
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build- | |
- name: Fetch mix dependencies | |
if: steps.deps-cache.outputs.cache-hit != 'true' | |
run: | | |
mix local.rebar --force | |
mix local.hex --force | |
mix deps.get | |
- name: Compile dependencies | |
if: steps.deps-cache.outputs.cache-hit != 'true' | |
run: mix deps.compile | |
- name: Compile application | |
run: mix compile |