This is a github action based largely on the public action delete-package-versions(source)
It is meant to be triggered by a github pull request closed action. When triggered, search the github graphql API for recent versions and loop over those to check if they match the input branch. Send the matching IDs back to the API with a delete mutation with that ID to clean up other versions.
The branch passed in can be the github branch directly. I'll downcase it and replace anything that isn't a letter, number, dash, or period with a dash to try to find the new version:
jk/9709/create_github_action will become jk-9709-create-github-action and then the version is checked with indexOf(), so 0.8.8-jk-9709-create-github-action.1 will match.
Install the dependencies
$ npm installBuild the typescript and package it for distribution
$ npm run build && npm run packageRun the tests ✔️
$ npm test
PASS ./index.test.js
✓ throws invalid number (3ms)
✓ wait 500 ms (504ms)
✓ test runs (95ms)
...The entrypoint is main.ts
See the toolkit documentation for the various packages.
The action.yml contains the definition of the inputs and output for this action.
Update the action.yml with your name, description, inputs and outputs for your action.
See the documentation
Actions are run from GitHub repos so we will checkin the packed dist folder.
Then run ncc and push the results:
$ npm run package
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1Note: We recommend using the --license option for ncc, which will create a license file for all of the production node modules used in your project.
Your action is now published! 🚀
See the versioning documentation
After testing you can create a version tag to reference the stable and latest V1 action.