Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @github/local-action and documentation #941

Merged
merged 4 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Do not commit your actual .env file to Git! This may contain secrets or other
# private information.

# Enable/disable step debug logging (default: `false`). For local debugging, it
# may be useful to set it to `true`.
ACTIONS_STEP_DEBUG=true

ncalteen marked this conversation as resolved.
Show resolved Hide resolved
# GitHub Actions inputs should follow `INPUT_<name>` format (case-sensitive).
# Hyphens should not be converted to underscores!
INPUT_MILLISECONDS=2400

# GitHub Actions default environment variables. These are set for every run of a
# workflow and can be used in your actions. Setting the value here will override
# any value set by the local-action tool.
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables

# CI="true"
# GITHUB_ACTION=""
# GITHUB_ACTION_PATH=""
# GITHUB_ACTION_REPOSITORY=""
# GITHUB_ACTIONS=""
# GITHUB_ACTOR=""
# GITHUB_ACTOR_ID=""
# GITHUB_API_URL=""
# GITHUB_BASE_REF=""
# GITHUB_ENV=""
# GITHUB_EVENT_NAME=""
# GITHUB_EVENT_PATH=""
# GITHUB_GRAPHQL_URL=""
# GITHUB_HEAD_REF=""
# GITHUB_JOB=""
# GITHUB_OUTPUT=""
# GITHUB_PATH=""
# GITHUB_REF=""
# GITHUB_REF_NAME=""
# GITHUB_REF_PROTECTED=""
# GITHUB_REF_TYPE=""
# GITHUB_REPOSITORY=""
# GITHUB_REPOSITORY_ID=""
# GITHUB_REPOSITORY_OWNER=""
# GITHUB_REPOSITORY_OWNER_ID=""
# GITHUB_RETENTION_DAYS=""
# GITHUB_RUN_ATTEMPT=""
# GITHUB_RUN_ID=""
# GITHUB_RUN_NUMBER=""
# GITHUB_SERVER_URL=""
# GITHUB_SHA=""
# GITHUB_STEP_SUMMARY=""
# GITHUB_TRIGGERING_ACTOR=""
# GITHUB_WORKFLOW=""
# GITHUB_WORKFLOW_REF=""
# GITHUB_WORKFLOW_SHA=""
# GITHUB_WORKSPACE=""
# RUNNER_ARCH=""
# RUNNER_DEBUG=""
# RUNNER_NAME=""
# RUNNER_OS=""
# RUNNER_TEMP=""
# RUNNER_TOOL_CACHE=""
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,4 @@ __tests__/runner/*

# IDE files
.idea
.vscode
*.code-workspace
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{

Check warning on line 1 in .vscode/launch.json

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.
"version": "0.2.0",
"configurations": [
{
"name": "Debug Action",
"type": "node",
"request": "launch",
"runtimeExecutable": "npx",
"cwd": "${workspaceRoot}",
"args": ["local-action", ".", "src/main.ts", ".env"],
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**", "node_modules/**"]
}
]
}
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,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 TypeScript 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.ts .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
Expand Down
Loading
Loading