-
Notifications
You must be signed in to change notification settings - Fork 63
73 lines (69 loc) · 3.05 KB
/
upgrade-dependencies.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
# https://www.oddbird.net/2022/06/01/dependabot-single-pull-request/
name: upgrade dependencies
on:
workflow_dispatch: # Allow running on-demand
schedule:
# Runs every Monday at 8:00 UTC (4:00 Eastern)
- cron: '0 8 * * 1'
jobs:
upgrade:
name: ${{ matrix.package }} (${{ matrix.os }}/py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['windows-latest', 'ubuntu-latest', 'macos-latest']
package: ["emmet-core", "emmet-builders", "emmet-api"]
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade Python dependencies
run: |
pip install -U pip pip-tools
cd ${{ matrix.package }}
pip-compile -q --upgrade -o requirements/${{ matrix.os }}_py${{ matrix.python-version }}.txt
pip-compile -q --upgrade --all-extras -o requirements/${{ matrix.os }}_py${{ matrix.python-version }}_extras.txt
- name: Detect changes
id: changes
run: |
git diff-index --quiet HEAD
echo "count=$?" >> $GITHUB_OUTPUT
test -z "$(git ls-files --exclude-standard --others)"
echo "files=$?" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
- name: commit & push changes
if: steps.changes.outputs.count > 0 || steps.changes.outputs.files > 0
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add ${{ matrix.package }}/requirements
git commit -m "update dependencies for ${{ matrix.package }} (${{ matrix.os }}/py${{ matrix.python-version }})"
git push -f origin ${{ github.ref_name }}:auto-dependency-upgrades-${{ matrix.package }}-${{ matrix.os }}-py${{ matrix.python-version }}
#pull_request:
# name: Merge all branches and open PR
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: merge all auto-dependency-upgrades branches
# id: changes
# run:
# git checkout -b auto-dependency-upgrades
# git branch -r | grep auto-dependency-upgrades- | git merge
# git branch -r | grep auto-dependency-upgrades- | cut -d/ -f2 | xargs -I {} git push origin :{}
# - name: Open pull request if needed
# if: steps.changes.outputs.count > 0
# env:
# GITHUB_TOKEN: ${{ secrets.PAT }}
# # Only open a PR if the branch is not attached to an existing one
# run: |
# PR=$(gh pr list --head auto-dependency-upgrades --json number -q '.[0].number')
# if [ -z $PR ]; then
# gh pr create \
# --head auto-dependency-upgrades \
# --title "Automated dependency upgrades" \
# --body "Full log: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# else
# echo "Pull request already exists, won't create a new one."
# fi