|
| 1 | +name: Update dependency lock file |
| 2 | + |
| 3 | +on: |
| 4 | + # Run every Monday at 08:00 UTC — picks up upstream patch / security |
| 5 | + # releases that land within the bounded ranges in requirements.txt. |
| 6 | + schedule: |
| 7 | + - cron: "0 8 * * 1" |
| 8 | + # Allow manual trigger from the Actions tab for ad-hoc refreshes. |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + pull-requests: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + update-lock: |
| 17 | + name: Regenerate requirements-lock.txt |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 21 | + |
| 22 | + - name: Set up Python |
| 23 | + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 |
| 24 | + with: |
| 25 | + python-version: "3.12" |
| 26 | + |
| 27 | + - name: Install pip-tools |
| 28 | + run: python -m pip install pip-tools |
| 29 | + |
| 30 | + - name: Regenerate lock file |
| 31 | + run: | |
| 32 | + pip-compile requirements.txt \ |
| 33 | + --output-file requirements-lock.txt \ |
| 34 | + --no-header \ |
| 35 | + --annotation-style=line \ |
| 36 | + --allow-unsafe \ |
| 37 | + --upgrade |
| 38 | +
|
| 39 | + - name: Restore header comment |
| 40 | + # pip-compile --no-header omits the auto-generated header line but |
| 41 | + # we maintain our own documentation header; restore it if missing. |
| 42 | + run: | |
| 43 | + HEADER='# Pinned lock file — generated by pip-compile (pip-tools).\n# Install: pip install -r requirements-lock.txt\n# Update: pip-compile requirements.txt --output-file requirements-lock.txt --no-header --annotation-style=line --allow-unsafe\n# Run periodically (e.g. via the "Update dependency lock file" CI workflow) to pick up\n# upstream patch / security releases within the bounded ranges in requirements.txt.' |
| 44 | + if ! head -1 requirements-lock.txt | grep -q "^#"; then |
| 45 | + printf '%s\n' "$HEADER" | cat - requirements-lock.txt > /tmp/lock.tmp |
| 46 | + mv /tmp/lock.tmp requirements-lock.txt |
| 47 | + fi |
| 48 | +
|
| 49 | + - name: Open PR if lock file changed |
| 50 | + uses: peter-evans/create-pull-request@v7 |
| 51 | + with: |
| 52 | + commit-message: "chore: update requirements-lock.txt" |
| 53 | + branch: "chore/update-lock-file" |
| 54 | + delete-branch: true |
| 55 | + title: "chore: update dependency lock file" |
| 56 | + body: | |
| 57 | + Automated weekly refresh of `requirements-lock.txt`. |
| 58 | +
|
| 59 | + Generated by `pip-compile --upgrade` from the bounded specifiers |
| 60 | + in `requirements.txt`. Review the diff to confirm no unexpected |
| 61 | + major-version jumps before merging. |
| 62 | + labels: dependencies |
0 commit comments