-
Notifications
You must be signed in to change notification settings - Fork 20
66 lines (58 loc) · 2.03 KB
/
cruft.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
name: Cruft Check
on:
pull_request:
branches:
- main
jobs:
cruft-check:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
# Avoid infinite loop where main
# Feature PR -> cruft check from main ->
# Cruft update PR -> cruft check from main ->
# Cruft update PR ...
- name: Check if pull request is from a fork
run: |
if [ "${{ github.event.pull_request.head.repo.fork }}" = "true" ]; then
echo "Pull request is from a fork and does not have permissions for PR creation. Exiting gracefully."
exit 0
elif [ "${{github.event.pull_request.title}}" == "ci - update cruft" ]; then
echo "Pull request is already a cruft update. Exiting gracefully."
exit 0
else
echo "Pull request is not from a fork, continuing."
fi
- name: Checkout code
uses: actions/checkout@v3
with:
ref: main
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install Cruft
run: pip install cruft
- name: Update cruft
id: cruft_check
run: |
cruft_output=$(cruft update --skip-apply-ask)
if echo "$cruft_output" | grep -q "Good work!"; then
echo "$cruft_output"
echo "cruft_updated=true" >> $GITHUB_OUTPUT
else
echo "$cruft_output"
echo "cruft_updated=false" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
if: ${{ steps.cruft_check.outputs.cruft_updated == 'true' && github.event.pull_request.title != 'ci - update cruft' }}
continue-on-error: true
with:
title: "ci - update cruft"
branch: "update-cruft"
body: "🌲 Cruft updates"
token: ${{ secrets.PAT }}
commit-message: "ci: update cruft"
labels: "dependencies" # This makes the PR exempt from the stale bot