Skip to content

Commit 3eafe7f

Browse files
Build assets on CI and add caching (#461)
1 parent 149d23f commit 3eafe7f

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

.github/workflows/assets.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Assets
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "v*.*"
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-22.04
12+
env:
13+
elixir: 1.14.0
14+
otp: 24.3
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: erlef/setup-beam@v1
19+
with:
20+
elixir-version: ${{ env.elixir }}
21+
otp-version: ${{ env.otp }}
22+
23+
- name: Cache Mix
24+
uses: actions/cache@v4
25+
with:
26+
path: |
27+
deps
28+
_build
29+
key: ${{ runner.os }}-mix-${{ env.elixir }}-${{ env.otp }}-${{ hashFiles('**/mix.lock') }}-dev
30+
restore-keys: |
31+
${{ runner.os }}-mix-${{ env.elixir }}-${{ env.otp }}-
32+
33+
- name: Install Dependencies
34+
run: mix deps.get --only dev
35+
36+
- name: Setup Node.js 18.x
37+
uses: actions/setup-node@v3
38+
with:
39+
node-version: 18
40+
41+
- name: Cache npm dependencies
42+
uses: actions/cache@v4
43+
with:
44+
path: ~/.npm
45+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
46+
restore-keys: |
47+
${{ runner.os }}-node-
48+
49+
- name: Install npm dependencies
50+
run: npm ci --prefix assets
51+
52+
- name: Build assets
53+
run: mix assets.build
54+
55+
- name: Push updated assets
56+
id: push_assets
57+
uses: stefanzweifel/git-auto-commit-action@v5
58+
with:
59+
commit_message: Update assets
60+
file_pattern: dist

.github/workflows/ci.yml

+28
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ jobs:
5151
otp-version: ${{matrix.pair.otp}}
5252
elixir-version: ${{matrix.pair.elixir}}
5353

54+
- name: Cache Mix
55+
uses: actions/cache@v4
56+
with:
57+
path: |
58+
deps
59+
_build
60+
key: ${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-${{ hashFiles('**/mix.lock') }}-test
61+
restore-keys: |
62+
${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-
63+
5464
- name: Install Dependencies
5565
run: mix deps.get --only test
5666

@@ -78,6 +88,16 @@ jobs:
7888
elixir-version: 1.14.0
7989
otp-version: 24.3
8090

91+
- name: Cache Mix
92+
uses: actions/cache@v4
93+
with:
94+
path: |
95+
deps
96+
_build
97+
key: ${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-${{ hashFiles('**/mix.lock') }}-test
98+
restore-keys: |
99+
${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-
100+
81101
- name: Install Dependencies
82102
run: mix deps.get --only test
83103

@@ -86,6 +106,14 @@ jobs:
86106
with:
87107
node-version: 18
88108

109+
- name: Cache npm dependencies
110+
uses: actions/cache@v4
111+
with:
112+
path: ~/.npm
113+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
114+
restore-keys: |
115+
${{ runner.os }}-node-
116+
89117
- name: npm install and test
90118
run: |
91119
cd assets

0 commit comments

Comments
 (0)