How to delete the deployment history of a repository in GitHub to show only the active?

You can create a github action to automatically delete deployments on the next commit (from this reply).
For example, if there is a deployment to github-pages, you can add the following entry to the workflow
jobs:
cleanup:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: 🗑 Delete deployment
uses: strumwolf/delete-deployment-environment@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment: github-pages
onlyRemoveDeployments: true
This action will delete all existing deployments on the specified environment (github-pages)
This action should be run before the deploy, so that there will be no record of the deploy in the environment, and the deploy that will run afterwards will create only 1 record.
To make sure that the deploy runs after cleaning, you can add it to your deploy process:
needs: cleanup
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With