Home > Net >  Remove git files/directories older than x days via GitHub Action
Remove git files/directories older than x days via GitHub Action

Time:01-16

We use a gh-pages branch in our repository to host a static website and frequently commit new information to this branch. Those files often get stale, as we push to a subdirectory per feature branch in the same repository.

The directory structure in my gh-pages branch is similar to the following:

.
|-- README.md
|-- JIRA-1234-feature
|   `-- graph
|-- JIRA-4567-bugfix
|   `-- graph
|-- JIRA-7890-branch-name
|   `-- testing

I want to remove directories via a GitHub actions for which the last update was more than 5 days ago.

I naively tried to remove them via find /path/to/files* -mtime 5 -exec rm {} ;, but the operating system obviously uses the clone date as the last modified time.

I also found

git ls-tree -r --name-only HEAD | while read filename; do
  echo "$(git log -1 --format="           
  • Related