Skip to content

Commit 2c9206c

Browse files
committedSep 6, 2024
Add @github/local-action and documentation
1 parent 4220638 commit 2c9206c

File tree

6 files changed

+806
-8
lines changed

6 files changed

+806
-8
lines changed
 

‎.env.example

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Do not commit your actual .env file to Git! This may contain secrets or other
2+
# private information.
3+
4+
# Enable/disable step debug logging (default: `false`). For local debugging, it
5+
# may be useful to set it to `true`.
6+
ACTIONS_STEP_DEBUG=true
7+
8+
# GitHub Actions inputs should follow `INPUT_<name>` format (case-sensitive).
9+
# Hyphens should not be converted to underscores!
10+
INPUT_MILLISECONDS=2400
11+
12+
# GitHub Actions default environment variables. These are set for every run of a
13+
# workflow and can be used in your actions. Setting the value here will override
14+
# any value set by the local-action tool.
15+
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
16+
17+
# CI="true"
18+
# GITHUB_ACTION=""
19+
# GITHUB_ACTION_PATH=""
20+
# GITHUB_ACTION_REPOSITORY=""
21+
# GITHUB_ACTIONS=""
22+
# GITHUB_ACTOR=""
23+
# GITHUB_ACTOR_ID=""
24+
# GITHUB_API_URL=""
25+
# GITHUB_BASE_REF=""
26+
# GITHUB_ENV=""
27+
# GITHUB_EVENT_NAME=""
28+
# GITHUB_EVENT_PATH=""
29+
# GITHUB_GRAPHQL_URL=""
30+
# GITHUB_HEAD_REF=""
31+
# GITHUB_JOB=""
32+
# GITHUB_OUTPUT=""
33+
# GITHUB_PATH=""
34+
# GITHUB_REF=""
35+
# GITHUB_REF_NAME=""
36+
# GITHUB_REF_PROTECTED=""
37+
# GITHUB_REF_TYPE=""
38+
# GITHUB_REPOSITORY=""
39+
# GITHUB_REPOSITORY_ID=""
40+
# GITHUB_REPOSITORY_OWNER=""
41+
# GITHUB_REPOSITORY_OWNER_ID=""
42+
# GITHUB_RETENTION_DAYS=""
43+
# GITHUB_RUN_ATTEMPT=""
44+
# GITHUB_RUN_ID=""
45+
# GITHUB_RUN_NUMBER=""
46+
# GITHUB_SERVER_URL=""
47+
# GITHUB_SHA=""
48+
# GITHUB_STEP_SUMMARY=""
49+
# GITHUB_TRIGGERING_ACTOR=""
50+
# GITHUB_WORKFLOW=""
51+
# GITHUB_WORKFLOW_REF=""
52+
# GITHUB_WORKFLOW_SHA=""
53+
# GITHUB_WORKSPACE=""
54+
# RUNNER_ARCH=""
55+
# RUNNER_DEBUG=""
56+
# RUNNER_NAME=""
57+
# RUNNER_OS=""
58+
# RUNNER_TEMP=""
59+
# RUNNER_TOOL_CACHE=""

‎.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,4 @@ __tests__/runner/*
9999

100100
# IDE files
101101
.idea
102-
.vscode
103102
*.code-workspace

‎.vscode/launch.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug Action",
6+
"type": "node",
7+
"request": "launch",
8+
"runtimeExecutable": "npx",
9+
"cwd": "${workspaceRoot}",
10+
"args": ["local-action", ".", "src/main.js", ".env"],
11+
"console": "integratedTerminal",
12+
"skipFiles": ["<node_internals>/**", "node_modules/**"]
13+
}
14+
]
15+
}

‎README.md

+28
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,34 @@ So, what are you waiting for? Go ahead and start customizing your action!
128128
> `ncc`, which will create a license file for all of the production node
129129
> modules used in your project.
130130
131+
1. (Optional) Test your action locally
132+
133+
The [`@github/local-action`](https://github.com/github/local-action) utility
134+
can be used to test your action locally. It is a simple command-line tool
135+
that "stubs" (or simulates) the GitHub Actions Toolkit. This way, you can run
136+
your JavaScript action locally without having to commit and push your changes
137+
to a repository.
138+
139+
The `local-action` utility can be run in the following ways:
140+
141+
- Visual Studio Code Debugger
142+
143+
Make sure to review and, if needed, update
144+
[`.vscode/launch.json`](./.vscode/launch.json)
145+
146+
- Terminal/Command Prompt
147+
148+
```bash
149+
# npx local action <action-yaml-path> <entrypoint> <dotenv-file>
150+
npx local-action . src/main.js .env
151+
```
152+
153+
You can provide a `.env` file to the `local-action` CLI to set environment
154+
variables used by the GitHub Actions Toolkit. For example, setting inputs and
155+
event payload data used by your action. For more information, see the example
156+
file, [`.env.example`](./.env.example), and the
157+
[GitHub Actions Documentation](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables).
158+
131159
1. Commit your changes
132160

133161
```bash

0 commit comments

Comments
 (0)