Skip to content

Update gha

Update gha #14

name: Validate Company Industry
on:
pull_request:
paths:
- "priv/companies/*.exs" # only run on changes to company files
jobs:
validate_struct:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Take ownership of the checkout directory (Git CVE-2022-24765)
run: chown --recursive --reference=/ .
- name: Allow for file ownership conflicts with Docker and GitHub Actions
run: git config --global --add safe.directory '*'
- id: beam
uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
version-type: strict
- id: cache
uses: actions/cache@v3
with:
key: |
${{ env.CACHE_VERSION }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-credo-${{ hashFiles('mix.lock') }}-${{ github.ref }}
restore-keys: |
${{ env.CACHE_VERSION }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-credo-${{ hashFiles('mix.lock') }}-${{ format('refs/heads/{0}', github.event.repository.default_branch) }}
${{ env.CACHE_VERSION }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-credo-
${{ env.CACHE_VERSION }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-
path: |
_build
deps
- if: steps.cache.outputs.cache-hit != 'true'
run: mix deps.get
- name: Get changed files
id: changed_files
run: |
changed_files=$(git log --name-only $(git merge-base main HEAD)..HEAD | grep priv/companies/)
echo "files=${changed_files}" >> $GITHUB_OUTPUT
- name: Run validation
run: |
for file in ${{ steps.changed_files.outputs.files }}; do
if [[ $file == *.exs ]]; then
mix validate_company_file $file
fi
done