Repository navigation
89 lines (79 loc) · 3.24 KB
/
Copy pathupdate-python-requirements.yml
File metadata and controls
89 lines (79 loc) · 3.24 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Update Python requirements
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "cvat/requirements/*.in"
- "utils/dataset_manifest/requirements.in"
permissions:
contents: read
pull-requests: read
jobs:
update:
# Only run on Dependabot branches from this repository. Regenerating
# requirements can execute package build code, so fork PRs must not run this
# workflow with access to the CVAT bot token.
if: >
github.event.pull_request.user.login == 'dependabot[bot]' &&
github.event.pull_request.head.repo.full_name == github.repository &&
startsWith(github.event.pull_request.head.ref, 'dependabot/pip/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
cargo \
g++ \
gcc \
libhdf5-dev \
libldap2-dev \
libmp3lame-dev \
libsasl2-dev \
make \
nasm \
pkg-config \
python3-dev
- name: Install pip-compile-multi
run: python -m pip install pip-compile-multi
- name: Regenerate Python requirements
run: cvat/requirements/regenerate.sh --no-upgrade
- name: Check generated requirements changes
id: changes
run: |
if git diff --quiet -- cvat/requirements/*.txt utils/dataset_manifest/requirements.txt; then
echo "No generated requirements changes"
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
# The default github.token does not trigger follow-up CI on push. Use the
# same app token as the release workflow so the updated Dependabot PR runs
# the normal validation pipeline.
- name: Generate authentication token
if: steps.changes.outputs.changed == 'true'
id: gen-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: "${{ secrets.CVAT_BOT_CLIENT_ID }}"
private-key: "${{ secrets.CVAT_BOT_PRIVATE_KEY }}"
- name: Commit regenerated requirements
if: steps.changes.outputs.changed == 'true'
env:
GH_TOKEN: "${{ steps.gen-token.outputs.token }}"
HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
git config user.name "cvat-bot[bot]"
git config user.email "147643061+cvat-bot[bot]@users.noreply.github.com"
git add cvat/requirements/*.txt utils/dataset_manifest/requirements.txt
git commit -m "Regenerate Python requirements"
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git"
git push origin "HEAD:$HEAD_REF"