machete #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: cleanup | |
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]" | |
git add . | |
git commit -m "Fix unused dependencies using cargo machete" | |
git push --set-upstream origin $BRANCH_NAME | |
- name: Create a Pull Request | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
base: main # The branch to merge the changes into | |
head: ${{ env.branch_name }} # Use the branch name from the previous step | |
title: "Fix unused dependencies" | |
body: "This PR removes unused dependencies from the project." | |
draft: false |