Skip to content

Workflow file for this run

name: Build the project code
on:
workflow_call:
inputs:
ref:
type: string
required: false
default: ""
cache_paths:
type: string
required: false
default: ""
mix-env:
type: string
required: false
default: test
elixir-code-path:
type: string
required: false
default: "."
secrets:
HEX_ORGANIZATION_COINGAMING_KEY:
required: true
SSH_KEYS:
required: false
OBAN_FINGERPRINT:
required: false
OBAN_LICENSE_KEY:
required: false
GH_TOKEN:
required: false
defaults:
run:
shell: bash
env:
MIX_ENV: ${{ inputs.mix-env }}
jobs:
build:
name: Build
runs-on: ubuntu-20.04
env:
OBAN_FINGERPRINT: ${{ secrets.OBAN_FINGERPRINT }}
OBAN_LICENSE_KEY: ${{ secrets.OBAN_LICENSE_KEY }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
submodules: recursive
token: ${{ secrets.GH_TOKEN != '' && secrets.GH_TOKEN || github.token }}
# When following job fails, it means you've changed .tool-versions
# and you must trigger machine.yml (build machine) workflow to build correct machine-cache
- name: Restore elixir and erlang
uses: actions/cache/restore@v3
id: machine-cache
with:
key: v2-release-${{ runner.os }}-amd64-${{ hashFiles('./.tool-versions') }}
path: |
~/.mix
~/.hex
~/.asdf
- name: Install Erlang, Elixir, etc
- uses: asdf-vm/actions/install@v2
- name: Install mix & hex and ex_env
if: steps.machine-cache.outputs.cache-hit != 'true'
run: |
mix local.hex --force
mix local.rebar --force
mix archive.install --force hex ex_env 0.3.2 --force
- name: Init Deps Cache
uses: actions/cache/restore@v3
id: deps-cache
with:
key: v2-release-${{ hashFiles(format('{0}/mix.lock', inputs.elixir-code-path)) }}-${{ inputs.mix-env }}
path: |
${{ inputs.cache_paths }}
~/.mix
~/.hex
~/.asdf
${{ inputs.elixir-code-path }}/deps
${{ inputs.elixir-code-path }}/_build
- name: Save elixir and erlang
if: steps.machine-cache.outputs.cache-hit != 'true'
uses: buildjet/cache/save@v3
id: machine-cache-save
with:
key: v2-release-${{ runner.os }}-amd64-${{ hashFiles('./.tool-versions') }}
path: |
~/.mix
~/.hex
~/.asdf
- name: Init Code Cache
uses: actions/cache/restore@v3
id: code-cache
with:
key: v2-release-${{ github.sha }}-${{ inputs.mix-env }}
path: |
${{ inputs.cache_paths }}
${{ inputs.elixir-code-path }}/deps
${{ inputs.elixir-code-path }}/_build
- name: SSH Deploy Keys Setup
uses: cardoe/ssh-agent-deploy-key@v1
with:
ssh-private-key: |
${{ secrets.SSH_KEYS }}
- name: Install protoc
run: sudo apt-get install protobuf-compiler
- name: Add coingaming organization
if: steps.deps-cache.outputs.cache-hit != 'true' && steps.code-cache.outputs.cache-hit != 'true'
run: |
cd ${{ inputs.elixir-code-path }}
mix hex.organization auth coingaming --key ${{secrets.HEX_ORGANIZATION_COINGAMING_KEY}}
- name: Add oban repo
if: steps.deps-cache.outputs.cache-hit != 'true' && env.OBAN_FINGERPRINT
run: |
cd ${{ inputs.elixir-code-path }}
mix hex.repo add oban https://getoban.pro/repo --fetch-public-key ${{env.OBAN_FINGERPRINT}} --auth-key ${{env.OBAN_LICENSE_KEY}}
- name: Authorize github.com
env:
GH_PAT: ${{ secrets.GH_TOKEN }}
GIT_TERMINAL_PROMPT: 0
run: |
git config --global --replace-all url."https://${GH_PAT}@github.com/".insteadOf git@github.com:
git config --global --add url."https://${GH_PAT}@github.com/".insteadOf "https://github.com/"
- name: Get deps and protobuf escript
if: steps.deps-cache.outputs.cache-hit != 'true' && steps.code-cache.outputs.cache-hit != 'true'
run: |
cd ${{ inputs.elixir-code-path }}
mix deps.get
mix escript.install hex protobuf 0.10.0 --force
echo "$HOME/.mix/escripts" >> $GITHUB_PATH
- name: Generate test proto files
if: steps.deps-cache.outputs.cache-hit != 'true' || steps.code-cache.outputs.cache-hit != 'true'
run: scripts/gen-test-proto.sh
continue-on-error: true
- name: Compile dependencies
if: steps.deps-cache.outputs.cache-hit != 'true' && steps.code-cache.outputs.cache-hit != 'true'
run: |
cd ${{ inputs.elixir-code-path }}
mix deps.compile
- name: Download UAInspector DB
if: steps.deps-cache.outputs.cache-hit != 'true' && steps.code-cache.outputs.cache-hit != 'true'
run: |
cd ${{ inputs.elixir-code-path }}
mix run --no-start -e "UAInspector.Downloader.download()"
continue-on-error: true
- name: Save Deps Cache
uses: actions/cache/save@v3
if: steps.deps-cache.outputs.cache-hit != 'true'
with:
key: v2-release-${{ hashFiles(format('{0}/mix.lock', inputs.elixir-code-path)) }}-${{ inputs.mix-env }}
path: |
${{ inputs.cache_paths }}
~/.mix
~/.hex
${{ inputs.elixir-code-path }}/deps
${{ inputs.elixir-code-path }}/_build
- name: Compile
if: steps.code-cache.outputs.cache-hit != 'true'
run: |
cd ${{ inputs.elixir-code-path }}
mix compile
- name: Save Code Cache
uses: actions/cache/save@v3
if: steps.code-cache.outputs.cache-hit != 'true'
with:
key: v2-release-${{ github.sha }}-${{ inputs.mix-env }}
path: |
${{ inputs.cache_paths }}
~/.mix
~/.hex
${{ inputs.elixir-code-path }}/deps
${{ inputs.elixir-code-path }}/_build