Skip to content

refactor: requiremnts workflows #1

refactor: requiremnts workflows

refactor: requiremnts workflows #1

Workflow file for this run

# Humans should not manage requirements.txt (bots do)
name: Validate requirements.txt not changed by human
on:
pull_request:
push:
jobs:
reject-drift:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if requirements.txt was modified unexpectedly
run: |
# Get author of last commit
AUTHOR=$(git log -1 --pretty=format:'%an')
# Check if requirements.txt was modified in last commit
if git diff --name-only HEAD~1 HEAD | grep -q "^requirements.txt$"; then
if [ "$AUTHOR" != "github-actions[bot]" ]; then
echo "::error::You may NOT edit 'requirements.txt'"
echo "::warning::Undo your changes to requirements.txt, so robot can maintain it."
echo "::notice::To pin dependencies, use 'poetry add <package-name>'."
exit 1
fi
fi
echo "`requirements.txt` unchanged"