-
Notifications
You must be signed in to change notification settings - Fork 1
87 lines (72 loc) · 3.17 KB
/
refresh-dev-cache.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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 (master).
# 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 master 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 master branch.
# When we push a new tag for a release, the actions/cache step will always miss
# and then check master 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:
- master
# 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 Dev 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:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_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 hex.organization auth cuatro --key $CUATRO_HEX_KEY
mix deps.get
- name: Compile dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: mix deps.compile
- name: Compile application
run: mix compile
# Generated by Elixir.Gaas.Generators.Simple.Actions.RefreshDevCache