-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
143 lines (126 loc) · 4.86 KB
/
action.yml
File metadata and controls
143 lines (126 loc) · 4.86 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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"
config-script:
description: >-
An optional Bash script to run before fetching and compiling dependencies.
May be used to configure Mix or Rebar3.
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: |
if [[ -z "${OTP_VERSION}" ]]; then OTP_VERSION="$(grep -oP "^erlang\s\K(.+)$" .tool-versions)"; fi
echo "otp-version=${OTP_VERSION}" >> "${GITHUB_OUTPUT}"
shell: bash
env:
OTP_VERSION: ${{ inputs.otp-version }}
- name: Set Elixir version
id: set-elixir-version
run: |
if [[ -z "${ELIXIR_VERSION}" ]]; then ELIXIR_VERSION="$(grep -oP "^elixir\s\K(.+)$" .tool-versions)"; fi
echo "elixir-version=${ELIXIR_VERSION}" >> "${GITHUB_OUTPUT}"
shell: bash
env:
ELIXIR_VERSION: ${{ inputs.elixir-version }}
- 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=${CACHE_KEY}-${{ runner.os }}-${OTP_VERSION}-${ELIXIR_VERSION}" >> "${GITHUB_OUTPUT}"
shell: bash
env:
CACHE_KEY: ${{ inputs.cache-key }}
ELIXIR_VERSION: ${{ steps.set-elixir-version.outputs.elixir-version }}
OTP_VERSION: ${{ steps.set-otp-version.outputs.otp-version }}
- name: Restore application build cache
uses: actions/cache@v5
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@v5
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@v5
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: Restore Rebar build tool cache
uses: actions/cache@v5
with:
path: ~/.cache/rebar3
key: rebar3-${{ steps.set-shared-cache-key.outputs.shared-cache-key }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
rebar3-${{ 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: Run configuration script
if: inputs.config-script != ''
run: /bin/bash -c "${CONFIG_SCRIPT}"
shell: bash
env:
CONFIG_SCRIPT: ${{ inputs.config-script }}
- 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 ${BUILD_FLAGS}
shell: bash
env:
BUILD_FLAGS: ${{ inputs.build-flags }}