Add @github/local-action and documentation

This commit is contained in:
Nick Alteen
2024-09-06 10:17:43 -04:00
parent 4220638be2
commit 2c9206ccfe
6 changed files with 806 additions and 8 deletions

View File

@@ -128,6 +128,34 @@ So, what are you waiting for? Go ahead and start customizing your action!
> `ncc`, which will create a license file for all of the production node
> modules used in your project.
1. (Optional) Test your action locally
The [`@github/local-action`](https://github.com/github/local-action) utility
can be used to test your action locally. It is a simple command-line tool
that "stubs" (or simulates) the GitHub Actions Toolkit. This way, you can run
your JavaScript action locally without having to commit and push your changes
to a repository.
The `local-action` utility can be run in the following ways:
- Visual Studio Code Debugger
Make sure to review and, if needed, update
[`.vscode/launch.json`](./.vscode/launch.json)
- Terminal/Command Prompt
```bash
# npx local action <action-yaml-path> <entrypoint> <dotenv-file>
npx local-action . src/main.js .env
```
You can provide a `.env` file to the `local-action` CLI to set environment
variables used by the GitHub Actions Toolkit. For example, setting inputs and
event payload data used by your action. For more information, see the example
file, [`.env.example`](./.env.example), and the
[GitHub Actions Documentation](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables).
1. Commit your changes
```bash