Someone tweeted about a niche Github Action idea:
https://twitter.com/tmcw/status/1626233552735211527
I pasted that tweet into chatGPT and it gave me an almost right answer.
The response created a new PR rather than updating the existing. So I said that it should update the existing and it gave m a new answer
It also included this explanation:
Here's what this workflow does:
- It is triggered by pull requests that are opened, reopened, or synchronized.
- It checks out the repository code using the actions/checkout action.
- It uses the grep command to find all TODO and FIXME comments in the codebase, excluding the .git, .github, and .vscode directories.
- If there are no TODO or FIXME comments, it sets the output variable to an empty string.
- If there are TODO or FIXME comments, it creates a pull request using the peter-evans/create-pull-request action.
- The pull request includes a to-do list with the found TODO and FIXME comments in the pull request description.
Note that you will need to have the peter-evans/create-pull-request action installed in your repository for this workflow to work. You can find more information about this action and how to use it in the GitHub Marketplace: https://github.com/marketplace/actions/create-pull-request.
The follow-up included this information:
Here's what's different in this updated workflow:
- The Update pull request step now uses the run key instead of the uses key.
- The run command uses the curl command to send a PATCH request to the GitHub API, updating the pull request with the new to-do list.
- The curl command uses the GITHUB_REPOSITORY and GITHUB_REF environment variables to construct the URL for the API request, and the secrets.GITHUB_TOKEN secret to authenticate the request.
- The sed command extracts the pull request number from the GITHUB_REF environment variable.
- The to-do list is URL-encoded using percent encoding so that it can be included in the API request.
With this updated workflow, the existing pull request will be updated with the to-do list each time the workflow is triggered by a pull request event.