Skip to content

Commit

Permalink
Adding new scheduled workflow machete.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mjovanc committed Nov 19, 2024
1 parent f1b6d32 commit c4ad13e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 11 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/machete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c4ad13e

Please sign in to comment.