-
-
Notifications
You must be signed in to change notification settings - Fork 20
66 lines (55 loc) · 2.03 KB
/
machete.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: machete
on:
schedule:
# Runs every Monday at 10:00 AM CET (which is 9:00 AM UTC)
- cron: '0 9 * * 1'
workflow_dispatch: # Allow manual triggering of the workflow
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install cargo-machete
run: cargo install cargo-machete
- name: Find Unused Dependencies
run: cargo machete --with-metadata
- name: Fix Unused Dependencies
run: cargo machete --fix
- name: Create a new branch for the changes
id: create_branch
run: |
# Generate a unique branch name based on the current date and time
BRANCH_NAME="cleanup-$(date +%Y%m%d%H%M%S)"
git checkout -b "$BRANCH_NAME"
echo "Created new branch $BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV # Set output for later steps
- name: Commit Changes
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
# Check if there are changes to commit
if [[ -n "$(git status --porcelain)" ]]; then
git add .
git commit -m "Fix unused dependencies using cargo machete"
git push --set-upstream origin $BRANCH_NAME
else
echo "No changes to commit."
fi
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ env.branch_name }}
base: main
title: "Fix unused dependencies"
body: "This PR fixes unused dependencies found by cargo machete."
commit-message: "machete: removing unused dependencies"
draft: "false"
labels: "dependencies, automated pr"
assignees: "mjovanc, chaseWillden"
continue-on-error: true