My Workflow
You probably know about The Most Useless Machine:
Let’s build it in GitHub Actions!
Submission Category:
Wacky Wildcards
Yaml File or Link to Code
.github/workflows/useless.yml
name: Useless
on:
issues:
types: [labeled]
pull_request:
types: [labeled]
jobs:
useless:
if: github.event.label.name == 'useless'
runs-on: ubuntu-latest
steps:
- name: Unlabel
run: |
curl -X DELETE "https://api.github.com/repos/$GITHUB_REPOSITORY/issues/${{ github.event.issue.number || github.event.pull_request.number }}/labels/useless?access_token=${{ secrets.GITHUB_TOKEN }}"
Additional Resources / Info
I did not build this workflow out of boredom, but out of neccessity. Sometimes I want to run a well-defined, manually-triggered job on a PR.
For example, if a test failed because I forgot to update the test snapshots, I might want to ask GitHub Actions to go ahead and update the snapshot file, and then commit it to my PR for me.
Or maybe I want to run the end-to-end browser-based test suite which can cost money. Therefore, running them on every single push may not be economically efficient. I want to run them just before merging to the main branch, as a pre-flight build.
And sometimes, situations may require me to run it multiple times. I want to be able to do that without having to push a new commit to trigger it. So, I thought it might be a good idea to designate a label to trigger GitHub Actions, and have it immediately unlabel the PR, so that it is ready for the next trigger.
Maybe this useless workflow isn’t so useless after all. Feel free to use this as a template for your workflows.