DEV Community

Ewerton Jordão
Ewerton Jordão

Posted on • Originally published at Medium on

GitHub Actions |How to remove all Failed Actions | PWSH ⚡ + GitHub API

Hello everyone, thank you very much for accessing this content, if you are here, you also use GitHub Actions and, of course, when you write an action sometimes that action fails, the action history grows and you need to remove it one by one of that history, it’s a boring task and you need to do it. What could facilitate this task? Okay, come on, we can make this task easier with PWSH7.

I wrote some Actions to automate tasks on my raspberry , my raspberry now it’s my Self Hosted Runner, In GitHub Actions you be able to use runners on plataform MacOS,Windows,Linux or Self Hosted in this particular mode, you need to management everything about admin tasks.

Before you need to have some things:

  1. Create a token on GitHub for connect on RestAPI (if you won’t provide this token you can’t interact with your GitHub Actions)
  2. PowerShell 7
  3. Secrests Managment(not mandatory but it’s cool to know)

Steps for create a token:

Click on your Avatar and select Settings
Click on your Avatar and select Settings

When open you profile ,select Developer Settings.
When open you profile ,select Developer Settings.

Personal access tokens  after click on Generate new token
Click on Personal access tokens after click on Generate new token

Flag those options
Flag those options

And apply these configurations
And apply these configurations

Now I show you the code 😃:It’s very simple after you had your personal access token, you need to know wich repository you want to make cleanup and that’s it 😃:

All workflows
All workflows

After run script remove jobs with failure status
After run script remove jobs with failure status

cleanup is done
cleanup is done

PowerShell Script:

That’s it. I really wish you appreciate this content, if you liked that content share with all. See you at next opportunity.

Top comments (0)