Skip to content

machete

machete #6

Workflow file for this run

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 "github-actions@github.com"
# 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"