-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
116 lines (101 loc) · 4 KB
/
action.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Setup Elixir Project
description: >-
Install Erlang/OTP and Elixir (and optionally Hex and Rebar); fetch, cache,
and compile dependencies; and build and cache the app.
inputs:
otp-version:
description: Erlang/OTP version to install. Reads from `.tool-versions` if unset.
elixir-version:
description: Elixir version to install. Reads from `.tool-versions` if unset.
install-hex:
description: Install Hex using `mix local.hex`.
default: true
install-rebar:
description: Install Rebar using `mix local.rebar`.
default: true
cache-key:
description: >-
An arbitrary string added to the derived cache key names. Set or change to
invalidate existing caches.
default: "v1"
build-app:
description: Compile application using `mix compile`.
default: true
build-flags:
description: Additional flags to pass to `mix compile`.
default: "--all-warnings"
outputs:
otp-version:
description: Exact Erlang/OTP version installed.
value: ${{ steps.setup-beam.outputs.otp-version }}
elixir-version:
description: Exact Elixir version installed.
value: ${{ steps.setup-beam.outputs.elixir-version }}
runs:
using: composite
steps:
- name: Set Erlang/OTP version
id: set-otp-version
run: |
otp_version="${{ inputs.otp-version }}"
if [ "${otp_version}" == "" ]; then otp_version="$(grep -oP "^erlang\s\K(.+)$" .tool-versions)"; fi
echo "otp-version=${otp_version}" >> "${GITHUB_OUTPUT}"
shell: bash
- name: Set Elixir version
id: set-elixir-version
run: |
elixir_version="${{ inputs.elixir-version }}"
if [ "${elixir_version}" == "" ]; then elixir_version="$(grep -oP "^elixir\s\K(.+)$" .tool-versions)"; fi
echo "elixir-version=${elixir_version}" >> "${GITHUB_OUTPUT}"
shell: bash
- name: Install Erlang/OTP and Elixir
uses: erlef/setup-beam@v1
id: setup-beam
with:
otp-version: ${{ steps.set-otp-version.outputs.otp-version }}
elixir-version: ${{ steps.set-elixir-version.outputs.elixir-version }}
version-type: ${{ (inputs.otp-version == '' || inputs.elixir-version == '') && 'stict' || 'loose' }}
- name: Set shared cache key
id: set-shared-cache-key
run: |
echo "shared-cache-key=${{ inputs.cache-key }}-${{ runner.os }}-${{ steps.set-otp-version.outputs.otp-version }}-${{ steps.set-elixir-version.outputs.elixir-version }}" >> "${GITHUB_OUTPUT}"
shell: bash
- name: Restore application build cache
uses: actions/cache@v4
with:
path: _build/${{env.MIX_ENV}}
key: build-${{ steps.set-shared-cache-key.outputs.shared-cache-key }}-${{ env.MIX_ENV }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
build-${{ steps.set-shared-cache-key.outputs.shared-cache-key }}-${{ env.MIX_ENV }}-
- name: Restore project dependencies cache
uses: actions/cache@v4
with:
path: deps
key: deps-${{ steps.set-shared-cache-key.outputs.shared-cache-key }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
deps-${{ steps.set-shared-cache-key.outputs.shared-cache-key }}-
- name: Restore Hex package manager cache
uses: actions/cache@v4
with:
path: ~/.hex
key: hex-${{ steps.set-shared-cache-key.outputs.shared-cache-key }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
hex-${{ steps.set-shared-cache-key.outputs.shared-cache-key }}-
- name: Install Hex package manager
if: inputs.install-hex == 'true'
run: mix local.hex --force
shell: bash
- name: Install Rebar build tool
if: inputs.install-rebar == 'true'
run: mix local.rebar --force
shell: bash
- name: Get out-of-date project dependencies
run: mix deps.get
shell: bash
- name: Compile project dependencies
run: mix loadpaths
shell: bash
- name: Compile application
if: inputs.build-app == 'true'
run: mix compile ${{ inputs.build-flags }}
shell: bash