Skip to content

Commit d565817

Browse files
committed
ci: skip update-reqs if nothing updated
1 parent 2e9d1f9 commit d565817

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

.github/workflows/update-reqs.yml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Netlify requires requirements.txt (humans do not)
22
# SEE: validate-reqs.yml
3-
name: Update requirements.txt
3+
name: Check/Update requirements.txt
44

55
on:
66
pull_request:
@@ -14,12 +14,47 @@ permissions:
1414
contents: write
1515

1616
jobs:
17-
update-requirements:
17+
check-requirements:
1818
runs-on: ubuntu-latest
19+
outputs:
20+
needs_update: ${{ steps.check.outputs.needs_update }}
1921

2022
# Skip if the last commit was from the bot (prevent infinite loops)
2123
if: github.event.head_commit.author.name != 'github-actions[bot]'
2224

25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
with:
29+
ref: ${{ github.head_ref || github.ref_name }}
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version-file: 'pyproject.toml'
35+
36+
- name: Install Poetry
37+
run: pip install poetry
38+
39+
- name: Check if requirements.txt needs update
40+
id: check
41+
run: |
42+
output=$(make requirements.txt 2>&1)
43+
echo "$output"
44+
45+
# Check if make indicates the file is up to date
46+
if echo "$output" | grep -qi "up to date\|up-to-date\|already up to date"; then
47+
echo "needs_update=false" >> $GITHUB_OUTPUT
48+
echo "::notice::requirements.txt is already up to date"
49+
else
50+
echo "needs_update=true" >> $GITHUB_OUTPUT
51+
fi
52+
53+
update-requirements:
54+
runs-on: ubuntu-latest
55+
needs: check-requirements
56+
if: needs.check-requirements.outputs.needs_update == 'true'
57+
2358
steps:
2459
- name: Checkout code
2560
uses: actions/checkout@v4

0 commit comments

Comments
 (0)