Skip to content

Instantly share code, notes, and snippets.

@solodyagin
Last active September 15, 2023 13:14
Show Gist options
  • Save solodyagin/0b51593fd661c236d52a689b7ad99711 to your computer and use it in GitHub Desktop.
Save solodyagin/0b51593fd661c236d52a689b7ad99711 to your computer and use it in GitHub Desktop.
Github: cleanup workflows

On your repository page, go to the Actions tab, then open the DevTools console and run the code below:

document.querySelectorAll('div#partial-actions-workflow-runs a.Link--primary').forEach(async a => {
  const url = a.href;
  console.log(url);

  const response = await fetch(url + '/delete', {
    headers: {
      'Accept': 'text/html',
      'X-Requested-With': 'XMLHttpRequest'
    }
  });
  if (response) {
    const data = await response.text();
    if (data) {
      const doc = new DOMParser().parseFromString(data, "text/html");
      if (doc) {
        const input = doc.querySelector('input[name="authenticity_token"]');
        if (input) {
          const token = input.value;
          await fetch(url, {
            method: 'POST',
            body: new URLSearchParams(`_method=delete&authenticity_token=${token}`)
          });
        }
      }
    }
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment