-
Notifications
You must be signed in to change notification settings - Fork 5
73 lines (62 loc) · 2.45 KB
/
update-requirements.yaml
File metadata and controls
73 lines (62 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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: Setup global variables
id: global_vars
run: |
echo "TODAYS_DAY=$(date '+%d')" >> $GITHUB_ENV # Ex.: 31
echo "TODAYS_MONTH=$(date '+%m')" >> $GITHUB_ENV # Ex.: 08
echo "TODAYS_YEAR=$(date '+%Y')" >> $GITHUB_ENV # Ex.: 2025
- name: Checkout repository
uses: actions/checkout@v4
with:
python-version: 3.11
- 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: Install pur and update requirements file
run: |
pip install --upgrade pur
pur -r requirements.txt
- name: Remove venv from git tracking
run: |
git clean -fdX venv
- name: Check for changes
id: check_changes
run: |
if git diff --exit-code requirements.txt; then
echo "changes=false" >> $GITHUB_ENV
else
echo "changes=true" >> $GITHUB_ENV
fi
- name: Create branch name
id: create_branch_name
run: |
echo "BRANCH=update-requirements-${{ env.TODAYS_YEAR }}-${{ env.TODAYS_MONTH }}-${{ env.TODAYS_DAY }}" >> $GITHUB_OUTPUT
- 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: ${{ steps.create_branch_name.outputs.BRANCH }}
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.'