Use this template to bootstrap the creation of a TypeScript action. 🚀
This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance.
Click the Use this Template
and provide the new repo details for your action
git clone https://github.com/bfra-me/github-action.git
cd github-action
pnpm install
pnpm run build
Run the tests ✔️
$ pnpm test
PASS ./index.test.js
✓ throws invalid number (3ms)
✓ wait 500 ms (504ms)
✓ test runs (95ms)
...
The action.yaml defines the inputs and output for your action.
Update the action.yaml with your name, description, inputs and outputs for your action.
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
import * as core from "@actions/core"
// ...
async function run() {
try {
// ...
} catch (error) {
core.setFailed(error.message)
}
}
run()
Actions are run from GitHub repos so we will check in the packed dist folder.
Then build and push the results:
pnpm run build
git add dist
git commit -a -m "prod dependencies"
git push origin releases/v1
Note: 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! 🚀
You can now validate the action by referencing ./
in a workflow in your repo (see ci.yaml).
uses: ./
with:
milliseconds: 1000
See the actions tab for runs of this action! 🚀
You can use this action in your workflows like this:
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run my action
uses: bfra-me/github-action@v2
with:
milliseconds: 1000