This repository has been archived by the owner on Oct 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
82 lines (78 loc) · 2.66 KB
/
requirements-pr.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
# cspell:ignore noreply
name: Requirements (PR)
on:
pull_request:
branches:
- main
- epic/*
jobs:
upgrade:
name: Upgrade pinned requirements
runs-on: ubuntu-20.04
strategy:
matrix:
python-version:
- 3.6
- 3.7
- 3.8
- 3.9
steps:
- uses: actions/checkout@v2
- run: git fetch origin
- name: Check for modified dependencies
id: git-diff
run:
echo "::set-output name=dependency-changes::$(git diff
origin/$GITHUB_BASE_REF --name-only -- .constraints/ setup.cfg)"
- name: Show dependency changes changes
run: git diff origin/$GITHUB_BASE_REF -- .constraints/ setup.cfg
- name: Abort if fork PR and dependency changes
if:
github.event.pull_request.head.repo.full_name != github.repository &&
steps.git-diff.outputs.dependency-changes != ''
run: |
echo "::error::Cannot modify package dependencies through a PR from a fork"
exit 1
- name: Set up Python ${{ matrix.python-version }}
if: steps.git-diff.outputs.dependency-changes != ''
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
if: steps.git-diff.outputs.dependency-changes != ''
run: |
python -m pip install --upgrade pip
pip install pip-tools
- name: Upgrade dependencies
if: steps.git-diff.outputs.dependency-changes != ''
run: bash .constraints/upgrade.sh
- uses: actions/upload-artifact@v2
with:
path: .constraints/py${{ matrix.python-version }}.txt
push:
name: Push changes
runs-on: ubuntu-20.04
needs:
- upgrade
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.PAT }}
- uses: actions/download-artifact@v2
with:
path: .constraints
- run: mv -f .constraints/artifact/* .constraints/
- run: git status -s
- name: Commit and push changes
run: |
git remote set-url origin https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }}
git config --global user.name "GitHub Action"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b ${GITHUB_HEAD_REF}
if [[ $(git status -s) ]]; then
git add -A
git commit -m "ci: upgrade pinned requirements (automatic)"
git config pull.rebase true
git pull origin ${GITHUB_HEAD_REF}
git push origin HEAD:${GITHUB_HEAD_REF}
fi