Skip to content

Commit

Permalink
Build assets on CI and add caching (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko authored Dec 4, 2024
1 parent 149d23f commit 3eafe7f
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/assets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Assets

on:
push:
branches:
- main
- "v*.*"

jobs:
build:
runs-on: ubuntu-22.04
env:
elixir: 1.14.0
otp: 24.3
steps:
- uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.elixir }}
otp-version: ${{ env.otp }}

- name: Cache Mix
uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ env.elixir }}-${{ env.otp }}-${{ hashFiles('**/mix.lock') }}-dev
restore-keys: |
${{ runner.os }}-mix-${{ env.elixir }}-${{ env.otp }}-
- name: Install Dependencies
run: mix deps.get --only dev

- name: Setup Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18

- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install npm dependencies
run: npm ci --prefix assets

- name: Build assets
run: mix assets.build

- name: Push updated assets
id: push_assets
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update assets
file_pattern: dist
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ jobs:
otp-version: ${{matrix.pair.otp}}
elixir-version: ${{matrix.pair.elixir}}

- name: Cache Mix
uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-${{ hashFiles('**/mix.lock') }}-test
restore-keys: |
${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-
- name: Install Dependencies
run: mix deps.get --only test

Expand Down Expand Up @@ -78,6 +88,16 @@ jobs:
elixir-version: 1.14.0
otp-version: 24.3

- name: Cache Mix
uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-${{ hashFiles('**/mix.lock') }}-test
restore-keys: |
${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-
- name: Install Dependencies
run: mix deps.get --only test

Expand All @@ -86,6 +106,14 @@ jobs:
with:
node-version: 18

- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: npm install and test
run: |
cd assets
Expand Down

0 comments on commit 3eafe7f

Please sign in to comment.