Skip to content

Commit 72351ee

Browse files
committed
feat: elixir code subpath parameter (WIP)
1 parent 8cd410b commit 72351ee

1 file changed

Lines changed: 31 additions & 16 deletions

File tree

.github/workflows/build.yml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ on:
2222
type: string
2323
required: false
2424
default: test
25+
elixir-code-path:
26+
type: string
27+
required: false
28+
default: "."
2529
secrets:
2630
HEX_ORGANIZATION_COINGAMING_KEY:
2731
required: true
@@ -65,19 +69,19 @@ jobs:
6569
with:
6670
ref: ${{ inputs.ref }}
6771
submodules: recursive
68-
token: ${{ secrets.GH_TOKEN }}
72+
token: ${{ secrets.GH_TOKEN != '' && secrets.GH_TOKEN || github.token }}
6973

7074
- name: Init Deps Cache
7175
uses: actions/cache/restore@v3
7276
id: deps-cache
7377
with:
74-
key: v2-release-${{ hashFiles('./mix.lock') }}-${{ inputs.mix-env }}
78+
key: v2-release-${{ hashFiles(format('./{0}/mix.lock', inputs.elixir-code-path)) }}-${{ inputs.mix-env }}
7579
path: |
7680
${{ inputs.cache_paths }}
7781
~/.mix
7882
~/.hex
79-
./deps
80-
./_build
83+
./${{ inputs.elixir-code-path }}/deps
84+
./${{ inputs.elixir-code-path }}/_build
8185
8286
- name: Init Code Cache
8387
uses: actions/cache/restore@v3
@@ -88,8 +92,8 @@ jobs:
8892
${{ inputs.cache_paths }}
8993
~/.mix
9094
~/.hex
91-
./deps
92-
./_build
95+
./${{ inputs.elixir-code-path }}/deps
96+
./${{ inputs.elixir-code-path }}/_build
9397
9498
- name: SSH Deploy Keys Setup
9599
uses: cardoe/ssh-agent-deploy-key@v1
@@ -102,11 +106,15 @@ jobs:
102106

103107
- name: Add coingaming organization
104108
if: steps.deps-cache.outputs.cache-hit != 'true' && steps.code-cache.outputs.cache-hit != 'true'
105-
run: mix hex.organization auth coingaming --key ${{secrets.HEX_ORGANIZATION_COINGAMING_KEY}}
109+
run: |
110+
cd ${{ inputs.elixir-code-path }}
111+
mix hex.organization auth coingaming --key ${{secrets.HEX_ORGANIZATION_COINGAMING_KEY}}
106112
107113
- name: Add oban repo
108114
if: steps.deps-cache.outputs.cache-hit != 'true' && env.OBAN_FINGERPRINT
109-
run: mix hex.repo add oban https://getoban.pro/repo --fetch-public-key ${{env.OBAN_FINGERPRINT}} --auth-key ${{env.OBAN_LICENSE_KEY}}
115+
run: |
116+
cd ${{ inputs.elixir-code-path }}
117+
mix hex.repo add oban https://getoban.pro/repo --fetch-public-key ${{env.OBAN_FINGERPRINT}} --auth-key ${{env.OBAN_LICENSE_KEY}}
110118
111119
- name: Authorize github.com
112120
env:
@@ -119,6 +127,7 @@ jobs:
119127
- name: Get deps and protobuf escript
120128
if: steps.deps-cache.outputs.cache-hit != 'true' && steps.code-cache.outputs.cache-hit != 'true'
121129
run: |
130+
cd ${{ inputs.elixir-code-path }}
122131
mix deps.get
123132
mix escript.install hex protobuf 0.10.0 --force
124133
echo "$HOME/.mix/escripts" >> $GITHUB_PATH
@@ -130,28 +139,34 @@ jobs:
130139

131140
- name: Compile dependencies
132141
if: steps.deps-cache.outputs.cache-hit != 'true' && steps.code-cache.outputs.cache-hit != 'true'
133-
run: mix deps.compile
142+
run: |
143+
cd ${{ inputs.elixir-code-path }}
144+
mix deps.compile
134145
135146
- name: Download UAInspector DB
136147
if: steps.deps-cache.outputs.cache-hit != 'true' && steps.code-cache.outputs.cache-hit != 'true'
137-
run: mix run --no-start -e "UAInspector.Downloader.download()"
148+
run: |
149+
cd ${{ inputs.elixir-code-path }}
150+
mix run --no-start -e "UAInspector.Downloader.download()"
138151
continue-on-error: true
139152

140153
- name: Save Deps Cache
141154
uses: actions/cache/save@v3
142155
if: steps.deps-cache.outputs.cache-hit != 'true'
143156
with:
144-
key: v2-release-${{ hashFiles('./mix.lock') }}-${{ inputs.mix-env }}
157+
key: v2-release-${{ hashFiles(format('./{0}/mix.lock', inputs.elixir-code-path)) }}-${{ inputs.mix-env }}
145158
path: |
146159
${{ inputs.cache_paths }}
147160
~/.mix
148161
~/.hex
149-
./deps
150-
./_build
162+
./${{ inputs.elixir-code-path }}/deps
163+
./${{ inputs.elixir-code-path }}/_build
151164
152165
- name: Compile
153166
if: steps.code-cache.outputs.cache-hit != 'true'
154-
run: mix compile
167+
run: |
168+
cd ${{ inputs.elixir-code-path }}
169+
mix compile
155170
156171
- name: Save Code Cache
157172
uses: actions/cache/save@v3
@@ -162,5 +177,5 @@ jobs:
162177
${{ inputs.cache_paths }}
163178
~/.mix
164179
~/.hex
165-
./deps
166-
./_build
180+
./${{ inputs.elixir-code-path }}/deps
181+
./${{ inputs.elixir-code-path }}/_build

0 commit comments

Comments
 (0)