Update gha #11
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
- 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: Dump GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJSON(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- name: Get changed files | |
id: changed_files | |
run: | | |
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) | |
if [ $? -ne 0 ]; then | |
echo "Error: git diff failed. Please check the commit history." >&2 | |
exit 1 | |
fi | |
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 |