Skip to content

Commit

Permalink
Feat: new workflow to check and update requirements.txt (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericsimard authored Jan 21, 2025
1 parent b8f12f7 commit bac5666
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/update-requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Update requirements.txt

on:
schedule:
- cron: '0 3 1 * *' # Runs every first day of the month @ 3 AM.
workflow_dispatch: # Allow manual runs

jobs:
update-requirements:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11 # Adjust to your required Python version

- name: Load secrets from 1Password
id: onepw_secrets
uses: 1password/load-secrets-action@v2.0.0
with:
export-env: true # Export loaded secrets as environment variables
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
GITHUB_TOKEN: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GitHub generic action token for all repos/credential"

- name: Create virtual environment
run: |
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
- name: Install pur
run: |
source venv/bin/activate
pip install pur
- name: Update requirements.txt
run: |
source venv/bin/activate
pur -r requirements.txt
- name: Check for changes
id: check_changes
run: |
if git diff --exit-code; then
echo "changes=false" >> $GITHUB_ENV
else
echo "changes=true" >> $GITHUB_ENV
fi
- name: Create Branch Name
id: createbranchname
if: env.changes == 'true'
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
run: |
branch_name="update-requirements-$(date +'%Y%m%d')"
echo "branchname=branch_name" >> $GITHUB_ENV
- name: Create Pull Request
id: createpr
if: env.changes == 'true'
uses: peter-evans/create-pull-request@v7.0.6
with:
token: ${{ env.GITHUB_TOKEN }}
sign-commits: true
assignees: "fredericsimard"
branch: ${{ env.branchname }}
commit-message: 'This PR updates the `requirements.txt` file with the latest versions of dependencies.'
title: 'Monthly `requirements.txt` update'
body: |
This PR updates the `requirements.txt` file with the latest versions of dependencies.

0 comments on commit bac5666

Please sign in to comment.