65 lines
1.6 KiB
YAML
65 lines
1.6 KiB
YAML
name: Update requirements.lock
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
- int
|
|
paths:
|
|
- 'requirements.txt'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
update-lock:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Install pip-tools
|
|
run: python -m pip install --upgrade "pip>=24,<26" pip-tools
|
|
|
|
- name: Generate requirements.lock
|
|
run: pip-compile requirements.txt -o requirements.lock
|
|
|
|
- name: Set environment file
|
|
run: |
|
|
if [ "${{ github.ref }}" == "refs/heads/int" ]; then
|
|
ENV_FILE="env-int.env"
|
|
else
|
|
ENV_FILE="env-prod.env"
|
|
fi
|
|
test -f "$ENV_FILE"
|
|
cp "$ENV_FILE" .env
|
|
|
|
- name: Install dependencies from generated lock
|
|
run: pip install -r requirements.lock --no-cache-dir
|
|
|
|
- name: Run tests
|
|
run: python -m pytest tests/ --ignore=tests/demo
|
|
|
|
- name: Clean up .env before commit
|
|
run: rm -f .env
|
|
|
|
- name: Commit and push requirements.lock
|
|
run: |
|
|
git config user.name "forgejo-actions[bot]"
|
|
git config user.email "forgejo-actions[bot]@noreply.git.poweron.swiss"
|
|
git add requirements.lock
|
|
if git diff --staged --quiet; then
|
|
echo "No changes to requirements.lock"
|
|
else
|
|
git commit -m "chore: update requirements.lock"
|
|
git push
|
|
fi
|