There's only one script in the repo. It marks images (PNG, JPG, JPEG) for deletion using git rm
based on whether or not they are referenced anywhere in the repo. There are multiple ways to run this script.
Additional documentation is available on my blog: https://www.stevemar.net/github-actions-rm-images/
There is a containerized version of the script available on Docker Hub. run this command from your project root:
docker run -v `pwd`:/source stevemar/image-deleter:latest
The script is also available as a GitHub Action. See this repo as an example. To use it in your repository perform the following:
-
Create a GitHub Secret with the key name
GH_TOKEN
and it's value be a GitHub API key. -
Create a file in
.github/workflows/
and paste the following code:on: push: branches: - master jobs: rm_old_images: runs-on: ubuntu-latest name: A job to remove images steps: - name: Checking out our code uses: actions/checkout@master - name: Remove the images uses: stevemar/image-deleter@v1.0.1 - name: Create Pull Request uses: peter-evans/create-pull-request@v3 with: token: ${{ secrets.GH_TOKEN }} commit-message: Remove unused images title: '[Automated PR] Remove unused images' body: | Found a few images that can be removed [1]: https://github.com/stevemar/image-deleter - name: Check outputs run: | echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
Just clone the repo, or copy and paste the code, and run it.
./rm-images.sh
If you want to re-build this with debug logs, just add this line to the Dockerfile
:
ENV DEBUG=true
Re-build it locally and run it.