-
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (87 loc) · 3.05 KB
/
precommitVersionBumps.yml
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
#------------------------------------------------------------------------------
# Lawrence McDaniel - https://lawrencemcdaniel.com
# Version Bump Workflow for .pre-commit-config.yaml
#
# This workflow runs on a cron schedule and checks for updates to the
# .pre-commit-config.yaml file. If updates are found, the workflow
# commits the changes to the next branch and pushes the changes to GitHub.
#
# This is a workaround for the fact that the pre-commit autoupdate command
# is not supported by Dependabot.
#------------------------------------------------------------------------------
name: pre-commit Version Bumps
on:
schedule:
- cron: "0 0 * * 3"
workflow_dispatch:
jobs:
evaluate_precommit_config:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Checkout next branch
run: |
git fetch
git checkout next
git pull origin next
- name: Cache NPM dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node
- name: Cache Python dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: locate site-packages path
shell: bash
run: |
echo "SITE_PACKAGES_PATH=$(python -c 'import site; print(site.getsitepackages()[0])')" >> $GITHUB_ENV
- name: Install pip
shell: bash
run: |
python -m pip install --upgrade pip
- name: Install dependencies
shell: bash
run: |
pip install -r ./requirements.txt
env:
SITE_PACKAGES_PATH: ${{ env.SITE_PACKAGES_PATH }}
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: "20.9.0"
- name: Install npm dev dependencies
run: npm install
- name: Update .pre-commit-config.yaml
run: |
pre-commit autoupdate
- name: Check for unstaged changes
id: check_changes
run: |
if [[ -n "$(git status --porcelain .pre-commit-config.yaml)" ]]; then
echo "::set-output name=changes::true"
else
echo "::set-output name=changes::false"
fi
- name: Commit and push changes
if: steps.check_changes.outputs.changes == 'true'
shell: bash
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .pre-commit-config.yaml
git commit -m "chore: [gh] version bumps in .pre-commit-config.yaml [skip ci]"
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:next