feat(ci): fail if there are changed files #9
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: Check generated files | |
on: [push] | |
jobs: | |
gen: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- name: Install tools | |
run: make install | |
- name: Generate code | |
run: | | |
# We need to start database and run migrations | |
docker compose up db -d | |
docker compose run migrate | |
# Regenerate code | |
make generate | |
# Cleanup | |
docker compose down | |
- name: Fail if there are changed files | |
run: | | |
CHANGED_FILES=$(git diff --name-only) | |
if [ -n "${CHANGED_FILES}" ]; then | |
echo "Your generated files are off. Don't forget to run 'make generate'. Files with changes:" | |
echo "${CHANGED_FILES}" | |
exit 1 | |
fi |