@ronaldphilipsen/local-action 0.0.0-stage → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.checkov.yml +3 -0
- package/.env.example +379 -0
- package/.github/codeql/codeql-config.yml +7 -0
- package/.github/copilot-instructions.md +79 -0
- package/.github/dependabot.yml +32 -0
- package/.github/workflows/codeql-analysis.yml +53 -0
- package/.github/workflows/continuous-delivery.yml +93 -0
- package/.github/workflows/continuous-integration.yml +382 -0
- package/.github/workflows/linter.yml +47 -0
- package/.github/workflows/release.yaml +100 -0
- package/.github/workflows/version-check.yml +44 -0
- package/.grype.yml +151 -0
- package/.markdown-lint.yml +7 -0
- package/.mega-linter.yml +188 -0
- package/.node-version +1 -0
- package/.prettierignore +4 -0
- package/.prettierrc.yml +14 -0
- package/.vscode/launch.json +15 -0
- package/.vscode/mcp.json +9 -0
- package/.vscode/settings.json +15 -0
- package/.vscode/tasks.json +51 -0
- package/.yaml-lint.yml +10 -0
- package/CHANGELOG.md +75 -0
- package/CODEOWNERS +3 -0
- package/CODE_OF_CONDUCT.md +74 -0
- package/CONTRIBUTING.md +140 -0
- package/LICENSE +21 -0
- package/README.md +277 -2
- package/SECURITY.md +42 -0
- package/SUPPORT.md +19 -0
- package/__fixtures__/@actions/core.ts +14 -0
- package/__fixtures__/@actions/exec.ts +9 -0
- package/__fixtures__/@actions/github.ts +3 -0
- package/__fixtures__/@actions/http-client.ts +9 -0
- package/__fixtures__/@actions/io.ts +9 -0
- package/__fixtures__/@octokit/rest.ts +18 -0
- package/__fixtures__/crypto.ts +7 -0
- package/__fixtures__/fs.ts +27 -0
- package/__fixtures__/javascript/no-export/.env.fixture +2 -0
- package/__fixtures__/javascript/no-export/action.yml +16 -0
- package/__fixtures__/javascript/no-export/node_modules/.gitkeep +0 -0
- package/__fixtures__/javascript/no-export/package.json +12 -0
- package/__fixtures__/javascript/no-export/src/index.js +0 -0
- package/__fixtures__/javascript/no-export/src/main.js +0 -0
- package/__fixtures__/javascript/no-import/.env.fixture +2 -0
- package/__fixtures__/javascript/no-import/action.yml +16 -0
- package/__fixtures__/javascript/no-import/node_modules/.gitkeep +0 -0
- package/__fixtures__/javascript/no-import/package.json +12 -0
- package/__fixtures__/javascript/no-import/src/index.js +3 -0
- package/__fixtures__/javascript/no-import/src/main.js +7 -0
- package/__fixtures__/javascript/success/.env.fixture +2 -0
- package/__fixtures__/javascript/success/action.yml +16 -0
- package/__fixtures__/javascript/success/node_modules/.gitkeep +0 -0
- package/__fixtures__/javascript/success/package.json +12 -0
- package/__fixtures__/javascript/success/post/index.js +3 -0
- package/__fixtures__/javascript/success/post/main.js +13 -0
- package/__fixtures__/javascript/success/pre/index.js +3 -0
- package/__fixtures__/javascript/success/pre/main.js +13 -0
- package/__fixtures__/javascript/success/src/index.js +3 -0
- package/__fixtures__/javascript/success/src/main.js +13 -0
- package/__fixtures__/javascript-esm/no-import/.env.fixture +2 -0
- package/__fixtures__/javascript-esm/no-import/action.yml +16 -0
- package/__fixtures__/javascript-esm/no-import/node_modules/.gitkeep +0 -0
- package/__fixtures__/javascript-esm/no-import/package.json +13 -0
- package/__fixtures__/javascript-esm/no-import/src/index.js +3 -0
- package/__fixtures__/javascript-esm/no-import/src/main.js +7 -0
- package/__fixtures__/javascript-esm/success/.env.fixture +2 -0
- package/__fixtures__/javascript-esm/success/action.yml +16 -0
- package/__fixtures__/javascript-esm/success/node_modules/.gitkeep +0 -0
- package/__fixtures__/javascript-esm/success/package.json +13 -0
- package/__fixtures__/javascript-esm/success/post/index.js +3 -0
- package/__fixtures__/javascript-esm/success/post/main.js +13 -0
- package/__fixtures__/javascript-esm/success/pre/index.js +3 -0
- package/__fixtures__/javascript-esm/success/pre/main.js +13 -0
- package/__fixtures__/javascript-esm/success/src/index.js +3 -0
- package/__fixtures__/javascript-esm/success/src/main.js +13 -0
- package/__fixtures__/path.ts +7 -0
- package/__fixtures__/payloads/issue_opened.json +33 -0
- package/__fixtures__/stream/promises.ts +3 -0
- package/__fixtures__/tsconfig-paths.ts +4 -0
- package/__fixtures__/typescript/no-import/.env.fixture +2 -0
- package/__fixtures__/typescript/no-import/action.yml +16 -0
- package/__fixtures__/typescript/no-import/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript/no-import/package.json +15 -0
- package/__fixtures__/typescript/no-import/src/index.ts +3 -0
- package/__fixtures__/typescript/no-import/src/main.ts +3 -0
- package/__fixtures__/typescript/no-import/tsconfig.json +20 -0
- package/__fixtures__/typescript/success/.env.fixture +2 -0
- package/__fixtures__/typescript/success/action.yml +16 -0
- package/__fixtures__/typescript/success/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript/success/package.json +15 -0
- package/__fixtures__/typescript/success/post/index.ts +3 -0
- package/__fixtures__/typescript/success/post/main.ts +9 -0
- package/__fixtures__/typescript/success/pre/index.ts +3 -0
- package/__fixtures__/typescript/success/pre/main.ts +9 -0
- package/__fixtures__/typescript/success/src/index.ts +3 -0
- package/__fixtures__/typescript/success/src/main.ts +9 -0
- package/__fixtures__/typescript/success/tsconfig.json +20 -0
- package/__fixtures__/typescript/success-yaml/.env.fixture +2 -0
- package/__fixtures__/typescript/success-yaml/action.yaml +16 -0
- package/__fixtures__/typescript/success-yaml/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript/success-yaml/package.json +15 -0
- package/__fixtures__/typescript/success-yaml/post/index.ts +3 -0
- package/__fixtures__/typescript/success-yaml/post/main.ts +9 -0
- package/__fixtures__/typescript/success-yaml/pre/index.ts +3 -0
- package/__fixtures__/typescript/success-yaml/pre/main.ts +9 -0
- package/__fixtures__/typescript/success-yaml/src/index.ts +3 -0
- package/__fixtures__/typescript/success-yaml/src/main.ts +9 -0
- package/__fixtures__/typescript/success-yaml/tsconfig.json +20 -0
- package/__fixtures__/typescript-esm/no-export/.env.fixture +2 -0
- package/__fixtures__/typescript-esm/no-export/action.yml +17 -0
- package/__fixtures__/typescript-esm/no-export/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript-esm/no-export/package.json +17 -0
- package/__fixtures__/typescript-esm/no-export/src/index.ts +0 -0
- package/__fixtures__/typescript-esm/no-export/src/main.ts +0 -0
- package/__fixtures__/typescript-esm/no-export/tsconfig.json +25 -0
- package/__fixtures__/typescript-esm/no-import/.env.fixture +2 -0
- package/__fixtures__/typescript-esm/no-import/action.yml +17 -0
- package/__fixtures__/typescript-esm/no-import/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript-esm/no-import/package.json +17 -0
- package/__fixtures__/typescript-esm/no-import/src/index.ts +3 -0
- package/__fixtures__/typescript-esm/no-import/src/main.ts +3 -0
- package/__fixtures__/typescript-esm/no-import/tsconfig.json +25 -0
- package/__fixtures__/typescript-esm/success/.env.fixture +2 -0
- package/__fixtures__/typescript-esm/success/action.yml +17 -0
- package/__fixtures__/typescript-esm/success/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript-esm/success/package.json +17 -0
- package/__fixtures__/typescript-esm/success/post/index.ts +3 -0
- package/__fixtures__/typescript-esm/success/post/main.ts +9 -0
- package/__fixtures__/typescript-esm/success/pre/index.ts +3 -0
- package/__fixtures__/typescript-esm/success/pre/main.ts +9 -0
- package/__fixtures__/typescript-esm/success/src/index.ts +3 -0
- package/__fixtures__/typescript-esm/success/src/main.ts +9 -0
- package/__fixtures__/typescript-esm/success/tsconfig.json +25 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/.env.fixture +2 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/action.yml +17 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/package.json +17 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/src/index.ts +3 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/src/main.ts +9 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/tsconfig.json +21 -0
- package/__tests__/command.test.ts +224 -0
- package/__tests__/stubs/artifact/internal/client.test.ts +340 -0
- package/__tests__/stubs/artifact/internal/delete/delete-artifact.test.ts +152 -0
- package/__tests__/stubs/artifact/internal/download/download-artifact.test.ts +119 -0
- package/__tests__/stubs/artifact/internal/find/get-artifact.test.ts +237 -0
- package/__tests__/stubs/artifact/internal/find/list-artifacts.test.ts +218 -0
- package/__tests__/stubs/artifact/internal/find/retry-options.test.ts +54 -0
- package/__tests__/stubs/artifact/internal/shared/config.test.ts +91 -0
- package/__tests__/stubs/artifact/internal/shared/errors.test.ts +38 -0
- package/__tests__/stubs/artifact/internal/shared/user-agent.test.ts +22 -0
- package/__tests__/stubs/artifact/internal/upload/path-and-artifact-name-validation.test.ts +53 -0
- package/__tests__/stubs/artifact/internal/upload/upload-artifact.test.ts +126 -0
- package/__tests__/stubs/artifact/internal/upload/upload-zip-specification.test.ts +49 -0
- package/__tests__/stubs/cache/cache.test.ts +357 -0
- package/__tests__/stubs/cache/errors.test.ts +55 -0
- package/__tests__/stubs/cache/internal/cacheUtils.test.ts +109 -0
- package/__tests__/stubs/cache/internal/constants.test.ts +81 -0
- package/__tests__/stubs/cache/internal/tar.test.ts +129 -0
- package/__tests__/stubs/core/core.test.ts +760 -0
- package/__tests__/stubs/core/path-utils.test.ts +45 -0
- package/__tests__/stubs/core/platform.test.ts +89 -0
- package/__tests__/stubs/core/summary.test.ts +455 -0
- package/__tests__/stubs/env.test.ts +72 -0
- package/__tests__/stubs/github/context.test.ts +73 -0
- package/__tests__/stubs/github/github.test.ts +15 -0
- package/__tests__/stubs/github/internal/utils.test.ts +98 -0
- package/__tests__/stubs/github/utils.test.ts +16 -0
- package/__tests__/utils/config.test.ts +78 -0
- package/__tests__/utils/output.test.ts +32 -0
- package/__tests__/utils/package.test.ts +33 -0
- package/badges/coverage.svg +1 -0
- package/bin/local-action.js +121 -0
- package/docs/create-a-job-summary.md +32 -0
- package/docs/debugging-in-vscode.md +27 -0
- package/docs/img/job-summary.png +0 -0
- package/docs/supported-functionality.md +126 -0
- package/eslint.config.mjs +74 -0
- package/jest.config.ts +41 -0
- package/package.json +93 -4
- package/src/command.ts +171 -0
- package/src/commands/run.ts +616 -0
- package/src/index.ts +21 -0
- package/src/stubs/artifact/artifact.ts +17 -0
- package/src/stubs/artifact/internal/client.ts +400 -0
- package/src/stubs/artifact/internal/delete/delete-artifact.ts +126 -0
- package/src/stubs/artifact/internal/download/download-artifact.ts +309 -0
- package/src/stubs/artifact/internal/find/get-artifact.ts +135 -0
- package/src/stubs/artifact/internal/find/list-artifacts.ts +188 -0
- package/src/stubs/artifact/internal/find/retry-options.ts +57 -0
- package/src/stubs/artifact/internal/shared/config.ts +64 -0
- package/src/stubs/artifact/internal/shared/errors.ts +53 -0
- package/src/stubs/artifact/internal/shared/interfaces.ts +195 -0
- package/src/stubs/artifact/internal/shared/user-agent.ts +13 -0
- package/src/stubs/artifact/internal/upload/path-and-artifact-name-validation.ts +92 -0
- package/src/stubs/artifact/internal/upload/upload-artifact.ts +127 -0
- package/src/stubs/artifact/internal/upload/upload-zip-specification.ts +108 -0
- package/src/stubs/artifact/internal/upload/zip.ts +122 -0
- package/src/stubs/cache/cache.ts +334 -0
- package/src/stubs/cache/errors.ts +31 -0
- package/src/stubs/cache/interfaces.ts +4 -0
- package/src/stubs/cache/internal/cacheUtils.ts +207 -0
- package/src/stubs/cache/internal/constants.ts +45 -0
- package/src/stubs/cache/internal/tar.ts +374 -0
- package/src/stubs/cache/options.ts +91 -0
- package/src/stubs/core/core.ts +743 -0
- package/src/stubs/core/path-utils.ts +39 -0
- package/src/stubs/core/platform.ts +132 -0
- package/src/stubs/core/summary.ts +399 -0
- package/src/stubs/env.ts +40 -0
- package/src/stubs/github/context.ts +94 -0
- package/src/stubs/github/github.ts +29 -0
- package/src/stubs/github/interfaces.ts +52 -0
- package/src/stubs/github/internal/utils.ts +83 -0
- package/src/stubs/github/utils.ts +52 -0
- package/src/types/quibble.d.ts +5 -0
- package/src/types.ts +116 -0
- package/src/utils/config.ts +47 -0
- package/src/utils/output.ts +20 -0
- package/src/utils/package.ts +38 -0
- package/tsconfig.base.json +29 -0
- package/tsconfig.eslint.json +22 -0
- package/tsconfig.json +18 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
All contributions are welcome and greatly appreciated! However, please try to
|
|
4
|
+
keep them limited in scope so that they can be more easily reviewed.
|
|
5
|
+
|
|
6
|
+
## Steps to Contribute
|
|
7
|
+
|
|
8
|
+
> [!WARNING]
|
|
9
|
+
>
|
|
10
|
+
> Check the `engine` property in [`package.json`](./package.json) to see what
|
|
11
|
+
> version of Node.js is required for local development. This can be different
|
|
12
|
+
> from the version of Node.js used on the GitHub Actions runners. Tools like
|
|
13
|
+
> [nodenv](https://github.com/nodenv/nodenv) can be used to manage your Node.js
|
|
14
|
+
> version automatically.
|
|
15
|
+
|
|
16
|
+
1. Fork this repository
|
|
17
|
+
1. Clone your fork
|
|
18
|
+
1. Install the dependencies with `npm install`
|
|
19
|
+
1. Make and test your changes
|
|
20
|
+
1. Commit your changes
|
|
21
|
+
|
|
22
|
+
Make sure to do the following when you commit your changes:
|
|
23
|
+
- Increase the version number in [`package.json`](./package.json)
|
|
24
|
+
- Run `npm install` to ensure dependencies are up to date
|
|
25
|
+
- Run `npm run all` to run formatting, linting, etc.
|
|
26
|
+
|
|
27
|
+
1. Open a pull request back to this repository
|
|
28
|
+
1. Notify the maintainers of this repository for peer review and approval
|
|
29
|
+
1. Merge :tada:
|
|
30
|
+
|
|
31
|
+
The maintainers of this repository will create a new release with your changes
|
|
32
|
+
so that everyone can enjoy your contributions!
|
|
33
|
+
|
|
34
|
+
## Testing
|
|
35
|
+
|
|
36
|
+
This project requires **100%** test coverage.
|
|
37
|
+
|
|
38
|
+
> [!IMPORTANT]
|
|
39
|
+
>
|
|
40
|
+
> It is critical that we have 100% test coverage to ensure that we are not
|
|
41
|
+
> introducing any regressions. All changes will be throughly tested by
|
|
42
|
+
> maintainers of this repository before a new release is created.
|
|
43
|
+
|
|
44
|
+
### Testing Local Updates
|
|
45
|
+
|
|
46
|
+
As you make changes, it's a great idea to run the `local-action` tool regularly
|
|
47
|
+
against various repositories with different configurations.
|
|
48
|
+
|
|
49
|
+
1. Symlink your package folder (this should only need to be done once)
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm link
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
1. Test your updated version
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
local-action run <path> <entrypoint> <dotenv file>
|
|
59
|
+
|
|
60
|
+
# Or...
|
|
61
|
+
npm exec local-action run <path> <entrypoint> <dotenv file>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Once you're finished testing, make sure to unlink!
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm unlink @github/local-action
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### Example Actions to Test
|
|
71
|
+
|
|
72
|
+
After making updates and running the test suite, please also make sure to test
|
|
73
|
+
your updates using the following GitHub Actions repositories:
|
|
74
|
+
|
|
75
|
+
- [`actions/javascript-action`](https://github.com/actions/javascript-action)
|
|
76
|
+
- [`actions/typescript-action`](https://github.com/actions/typescript-action)
|
|
77
|
+
|
|
78
|
+
1. Clone each repository locally
|
|
79
|
+
1. From your `github/local-action` fork, test each action
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm exec local-action \
|
|
83
|
+
"/<action repository clone path>/typescript-action" \
|
|
84
|
+
"src/main.ts" \
|
|
85
|
+
"<path to your .env file>"
|
|
86
|
+
|
|
87
|
+
npm exec local-action \
|
|
88
|
+
"/<action repository clone path>/javascript-action" \
|
|
89
|
+
"src/main.ts" \
|
|
90
|
+
"<path to your .env file>"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
For an example `.env` file to use for testing, see
|
|
94
|
+
[`.env.example`](./.env.example).
|
|
95
|
+
|
|
96
|
+
### Running the Test Suite
|
|
97
|
+
|
|
98
|
+
Simply run the following command to invoke the entire test suite:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm run test
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
> [!NOTE]
|
|
105
|
+
>
|
|
106
|
+
> This requires that you have already run `npm install`
|
|
107
|
+
|
|
108
|
+
### Toolkit Stub Updates
|
|
109
|
+
|
|
110
|
+
When updating any of the supported stubs for the GitHub Actions Toolkit, please
|
|
111
|
+
make sure to also update the following. This helps ensure that we are using the
|
|
112
|
+
latest supported versions of the toolkit packages, and makes comparing changes
|
|
113
|
+
across commits easier.
|
|
114
|
+
|
|
115
|
+
1. The supported version in the [`README.md`](./README.md)
|
|
116
|
+
|
|
117
|
+
```markdown
|
|
118
|
+
| Package | Version |
|
|
119
|
+
| ---------------------------------------------------------------------- | -------- |
|
|
120
|
+
| [`@actions/artifact`](https://www.npmjs.com/package/@actions/artifact) | `2.3.2` |
|
|
121
|
+
| [`@actions/core`](https://www.npmjs.com/package/@actions/core) | `1.11.1` |
|
|
122
|
+
| [`@actions/github`](https://www.npmjs.com/package/@actions/github) | `6.0.1` |
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
1. The latest reviewed commit URL in the corresponding `src/stubs/*.ts` file
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
/**
|
|
129
|
+
* Last Reviewed Commit: https://github.com/actions/toolkit/blob/f58042f9cc16bcaa87afaa86c2974a8c771ce1ea/packages/artifact/src/artifact.ts
|
|
130
|
+
* Last Reviewed Date: 2025-09-10
|
|
131
|
+
*/
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
When comparing commits to see what has been updated in the toolkit packages, be
|
|
135
|
+
sure to compare against the last reviewed commit in the corresponding stub file.
|
|
136
|
+
This can be done more easily using the following URL format:
|
|
137
|
+
|
|
138
|
+
```plain
|
|
139
|
+
https://github.com/actions/toolkit/compare/<old commit>..main
|
|
140
|
+
```
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright GitHub
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,278 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Local Action Debugger
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
Run custom GitHub Actions locally and test them in Visual Studio Code!
|
|
8
|
+
|
|
9
|
+
This command-line tool emulates some **basic** functionality of the
|
|
10
|
+
[GitHub Actions Toolkit](https://github.com/actions/toolkit) so that custom
|
|
11
|
+
actions can be run directly on your workstation.
|
|
12
|
+
|
|
13
|
+
> [!NOTE]
|
|
14
|
+
>
|
|
15
|
+
> This tool currently only supports JavaScript and TypeScript actions!
|
|
16
|
+
|
|
17
|
+
The following table tracks the versions of the GitHub Actions Toolkit that are
|
|
18
|
+
currently implemented by this tool.
|
|
19
|
+
|
|
20
|
+
| Package | Version |
|
|
21
|
+
| ---------------------------------------------------------------------- | ------- |
|
|
22
|
+
| [`@actions/artifact`](https://www.npmjs.com/package/@actions/artifact) | `5.0.2` |
|
|
23
|
+
| [`@actions/cache`](https://www.npmjs.com/package/@actions/cache) | `5.0.3` |
|
|
24
|
+
| [`@actions/core`](https://www.npmjs.com/package/@actions/core) | `2.0.2` |
|
|
25
|
+
| [`@actions/github`](https://www.npmjs.com/package/@actions/github) | `7.0.0` |
|
|
26
|
+
|
|
27
|
+
## Changelog
|
|
28
|
+
|
|
29
|
+
See the [CHANGELOG](./CHANGELOG.md) for a complete list of changes.
|
|
30
|
+
|
|
31
|
+
## Node.js Version Support
|
|
32
|
+
|
|
33
|
+
This tool is currently tested against **Node.js versions 22 and 24**. It is not
|
|
34
|
+
guaranteed to work with other versions at this time.
|
|
35
|
+
|
|
36
|
+
## Package Manager Support
|
|
37
|
+
|
|
38
|
+
### `npm` Support
|
|
39
|
+
|
|
40
|
+
This tool is designed primarily for use with `npm` and `npx`. It is recommended
|
|
41
|
+
to use `npm` for managing actions you wish to test with this tool.
|
|
42
|
+
|
|
43
|
+
### `pnpm` Support
|
|
44
|
+
|
|
45
|
+
This tool ships with **experimental** support for `pnpm`. If you encounter any
|
|
46
|
+
issues, please [file an issue](https://github.com/github/local-action/issues).
|
|
47
|
+
|
|
48
|
+
Some caveats to this support are listed below.
|
|
49
|
+
|
|
50
|
+
- This tool does not support CommonJS actions using `pnpm`.
|
|
51
|
+
|
|
52
|
+
### `yarn` Support
|
|
53
|
+
|
|
54
|
+
This tool ships with **experimental** support for `yarn`. If you encounter any
|
|
55
|
+
issues, please [file an issue](https://github.com/github/local-action/issues).
|
|
56
|
+
|
|
57
|
+
Some caveats to this support are listed below.
|
|
58
|
+
|
|
59
|
+
- The `@github/local-action` package should be run using
|
|
60
|
+
`yarn dlx @github/local-action` instead of `yarn local-action`.
|
|
61
|
+
- This tool does not support CommonJS actions using `yarn`.
|
|
62
|
+
|
|
63
|
+
## Prerequisites
|
|
64
|
+
|
|
65
|
+
### Installed Tools
|
|
66
|
+
|
|
67
|
+
- [Node.js and npm](https://nodejs.org/en)
|
|
68
|
+
|
|
69
|
+
### Action Structure
|
|
70
|
+
|
|
71
|
+
For JavaScript and TypeScript actions, your code should follow the format of the
|
|
72
|
+
corresponding template repository.
|
|
73
|
+
|
|
74
|
+
- [`actions/javascript-action`](https://github.com/actions/javascript-action)
|
|
75
|
+
- [`actions/typescript-action`](https://github.com/actions/typescript-action)
|
|
76
|
+
|
|
77
|
+
Specifically, there should be a separation between the entrypoint used by GitHub
|
|
78
|
+
Actions when invoking your code, and the actual logic of your action. For
|
|
79
|
+
example:
|
|
80
|
+
|
|
81
|
+
#### Entrypoint: **`index.ts`**
|
|
82
|
+
|
|
83
|
+
This is what is invoked by GitHub Actions when your action is run.
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
/**
|
|
87
|
+
* This file is the entrypoint for the action
|
|
88
|
+
*/
|
|
89
|
+
import { run } from './main'
|
|
90
|
+
|
|
91
|
+
// It calls the actual logic of the action
|
|
92
|
+
run()
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### Logic: **`main.ts`**
|
|
96
|
+
|
|
97
|
+
This is the actual implementation of your action. It is called by the
|
|
98
|
+
entrypoint.
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import * as core from '@actions/core'
|
|
102
|
+
import { wait } from './wait'
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* This file is the actual logic of the action
|
|
106
|
+
* @returns {Promise<void>} Resolves when the action is complete
|
|
107
|
+
*/
|
|
108
|
+
export async function run(): Promise<void> {
|
|
109
|
+
// ...
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Transpiled Actions
|
|
114
|
+
|
|
115
|
+
Depending on how you build your JavaScript/TypeScript actions, you may do one of
|
|
116
|
+
the following when preparing for release:
|
|
117
|
+
|
|
118
|
+
- Commit the `node_modules` directory to your repository
|
|
119
|
+
- Transpile your code and dependencies using tools like
|
|
120
|
+
[`tsc`](https://www.typescriptlang.org/docs/handbook/compiler-options.html),
|
|
121
|
+
[`@vercel/ncc`](https://www.npmjs.com/package/@vercel/ncc), or
|
|
122
|
+
[`rollup`](https://rollupjs.org/)
|
|
123
|
+
|
|
124
|
+
**This tool supports non-transpiled action code only.** This is because it uses
|
|
125
|
+
[`quibble`](https://github.com/testdouble/quibble) to override GitHub Actions
|
|
126
|
+
Toolkit dependencies (e.g
|
|
127
|
+
[`@actions/core`](https://www.npmjs.com/package/@actions/core)). In transpiled
|
|
128
|
+
code, this simply doesn't work.
|
|
129
|
+
|
|
130
|
+
For example, if you have a TypeScript action that follows the same format as the
|
|
131
|
+
[template](https://github.com/actions/typescript-action), you would have both
|
|
132
|
+
`src` and `dist` directories in your repository. The `dist` directory contains
|
|
133
|
+
the transpiled code with any dependencies included. When running this utility,
|
|
134
|
+
you will want to target the code files in the `src` directory instead (including
|
|
135
|
+
the dependencies this tool wants to replace). This has the added benefit of
|
|
136
|
+
being able to hook into debugging utilities in your IDE :tada:
|
|
137
|
+
|
|
138
|
+
For additional information about transpiled action code, see
|
|
139
|
+
[Commit, tag, and push your action to GitHub](https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action#commit-tag-and-push-your-action-to-github).
|
|
140
|
+
|
|
141
|
+
## Installation
|
|
142
|
+
|
|
143
|
+
### Option 1: Install from npm
|
|
144
|
+
|
|
145
|
+
1. Install via `npm`
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
npm i -g @github/local-action
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Option 2: Clone this Repository
|
|
152
|
+
|
|
153
|
+
1. Clone this repository locally
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
git clone https://github.com/github/local-action.git
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
1. Install dependencies
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
npm ci
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
1. Install via `npm`
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
npm i -g .
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Alternatively, you can link the package if you want to make code changes
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
npm link .
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Commands
|
|
178
|
+
|
|
179
|
+
### `local-action`
|
|
180
|
+
|
|
181
|
+
| Option | Description |
|
|
182
|
+
| ----------------- | --------------------------- |
|
|
183
|
+
| `-h`, `--help` | Display help information |
|
|
184
|
+
| `-V`, `--version` | Display version information |
|
|
185
|
+
|
|
186
|
+
### `local-action run <path> <logic entrypoint> <dotenv file> [--pre <pre entrypoint>] [--post <post entrypoint>]`
|
|
187
|
+
|
|
188
|
+
| Argument | Description |
|
|
189
|
+
| -------------------------- | ------------------------------------------------------------------- |
|
|
190
|
+
| `path` | Path to the local action directory |
|
|
191
|
+
| | Example: `/path/to/action.yml` |
|
|
192
|
+
| `logic entrypoint` | Action logic entrypoint (relative to action directory) |
|
|
193
|
+
| | Example: `src/main.ts` |
|
|
194
|
+
| `dotenv file` | Path to the local `.env` file for action inputs |
|
|
195
|
+
| | Example: `/path/to/.env` |
|
|
196
|
+
| | See the example [`.env.example`](.env.example) |
|
|
197
|
+
| `--pre <pre entrypoint>` | (Optional) `pre` command entrypoint (relative to action directory) |
|
|
198
|
+
| | Example: `pre/main.ts` |
|
|
199
|
+
| `--post <post entrypoint>` | (Optional) `post` command entrypoint (relative to action directory) |
|
|
200
|
+
| | Example: `post/main.ts` |
|
|
201
|
+
|
|
202
|
+
Examples:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
local-action run /path/to/typescript-action src/main.ts .env --pre pre/main.ts --post post/main.ts
|
|
206
|
+
|
|
207
|
+
# The `run` action is invoked by default as well
|
|
208
|
+
local-action /path/to/typescript-action src/main.ts .env --pre pre/main.ts --post post/main.ts
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### Output
|
|
212
|
+
|
|
213
|
+
```console
|
|
214
|
+
$ local-action run /path/to/typescript-action src/main.ts .env --pre pre/main.ts --post post/main.ts
|
|
215
|
+
_ _ _ ____ _
|
|
216
|
+
/ \ ___| |_(_) ___ _ __ | _ \ ___| |__ _ _ __ _ __ _ ___ _ __
|
|
217
|
+
/ _ \ / __| __| |/ _ \| '_ \ | | | |/ _ \ '_ \| | | |/ _` |/ _` |/ _ \ '__|
|
|
218
|
+
/ ___ \ (__| |_| | (_) | | | | | |_| | __/ |_) | |_| | (_| | (_| | __/ |
|
|
219
|
+
/_/ \_\___|\__|_|\___/|_| |_| |____/ \___|_.__/ \__,_|\__, |\__, |\___|_|
|
|
220
|
+
|___/ |___/
|
|
221
|
+
================================================================================
|
|
222
|
+
Configuration
|
|
223
|
+
================================================================================
|
|
224
|
+
|
|
225
|
+
┌─────────┬────────────────────┬───────────────────────────────────────────┐
|
|
226
|
+
│ (index) │ Field │ Value │
|
|
227
|
+
├─────────┼────────────────────┼───────────────────────────────────────────┤
|
|
228
|
+
│ 0 │ 'Action Path' │ '/path/to/typescript-action' │
|
|
229
|
+
│ 1 │ 'Entrypoint' │ '/path/to/typescript-action/src/main.ts' │
|
|
230
|
+
│ 2 │ 'Environment File' │ '/path/to/local-action-debugger/.env' │
|
|
231
|
+
└─────────┴────────────────────┴───────────────────────────────────────────┘
|
|
232
|
+
|
|
233
|
+
================================================================================
|
|
234
|
+
Action Metadata
|
|
235
|
+
================================================================================
|
|
236
|
+
|
|
237
|
+
┌─────────┬────────────────┬───────────────────────────────┐
|
|
238
|
+
│ (index) │ Input │ Description │
|
|
239
|
+
├─────────┼────────────────┼───────────────────────────────┤
|
|
240
|
+
│ 0 │ 'milliseconds' │ 'Your input description here' │
|
|
241
|
+
└─────────┴────────────────┴───────────────────────────────┘
|
|
242
|
+
|
|
243
|
+
┌─────────┬────────┬────────────────────────────────┐
|
|
244
|
+
│ (index) │ Output │ Description │
|
|
245
|
+
├─────────┼────────┼────────────────────────────────┤
|
|
246
|
+
│ 0 │ 'time' │ 'Your output description here' │
|
|
247
|
+
└─────────┴────────┴────────────────────────────────┘
|
|
248
|
+
|
|
249
|
+
================================================================================
|
|
250
|
+
Running Action
|
|
251
|
+
================================================================================
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## (TypeScript) TSConfig Requirements
|
|
255
|
+
|
|
256
|
+
If you are testing TypeScript actions, there are a few settings that **must** be
|
|
257
|
+
configured in your `tsconfig.json` file (either explicitly or via their default
|
|
258
|
+
values).
|
|
259
|
+
|
|
260
|
+
| Property | Required Value |
|
|
261
|
+
| ------------------------------------------------------------- | -------------- |
|
|
262
|
+
| [`allowJs`](https://www.typescriptlang.org/tsconfig/#allowJs) | `false` |
|
|
263
|
+
|
|
264
|
+
### Troubleshooting
|
|
265
|
+
|
|
266
|
+
Possible errors that can arise from not having `allowJs: false`:
|
|
267
|
+
|
|
268
|
+
- `TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file` from tsx
|
|
269
|
+
when trying to run `npx @github/local-action`.
|
|
270
|
+
|
|
271
|
+
## Features
|
|
272
|
+
|
|
273
|
+
The following list links to documentation on how to use various features of the
|
|
274
|
+
`local-action` tool.
|
|
275
|
+
|
|
276
|
+
- [Supported Functionality](./docs//supported-functionality.md)
|
|
277
|
+
- [Debugging in Visual Studio Code](./docs/debugging-in-vscode.md)
|
|
278
|
+
- [Create a Job Summary](./docs/create-a-job-summary.md)
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
Thanks for helping make GitHub safe for everyone!
|
|
4
|
+
|
|
5
|
+
GitHub takes the security of our software products and services seriously,
|
|
6
|
+
including all of the open source code repositories managed through our GitHub
|
|
7
|
+
organizations, such as [GitHub](https://github.com/GitHub).
|
|
8
|
+
|
|
9
|
+
Even though
|
|
10
|
+
[open source repositories are outside of the scope of our bug bounty program](https://bounty.github.com/index.html#scope)
|
|
11
|
+
and therefore not eligible for bounty rewards, we will ensure that your finding
|
|
12
|
+
gets passed along to the appropriate maintainers for remediation.
|
|
13
|
+
|
|
14
|
+
## Reporting Security Issues
|
|
15
|
+
|
|
16
|
+
If you believe you have found a security vulnerability in any GitHub-owned
|
|
17
|
+
repository, please report it to us through coordinated disclosure.
|
|
18
|
+
|
|
19
|
+
**Please do not report security vulnerabilities through public GitHub issues,
|
|
20
|
+
discussions, or pull requests.**
|
|
21
|
+
|
|
22
|
+
Instead, please send an email to
|
|
23
|
+
[opensource-security@github.com](mailto:opensource-security@github.com).
|
|
24
|
+
|
|
25
|
+
Please include as much of the information listed below as you can to help us
|
|
26
|
+
better understand and resolve the issue:
|
|
27
|
+
|
|
28
|
+
- The type of issue (e.g., buffer overflow, SQL injection, or cross-site
|
|
29
|
+
scripting)
|
|
30
|
+
- Full paths of source file(s) related to the manifestation of the issue
|
|
31
|
+
- The location of the affected source code (tag/branch/commit or direct URL)
|
|
32
|
+
- Any special configuration required to reproduce the issue
|
|
33
|
+
- Step-by-step instructions to reproduce the issue
|
|
34
|
+
- Proof-of-concept or exploit code (if possible)
|
|
35
|
+
- Impact of the issue, including how an attacker might exploit the issue
|
|
36
|
+
|
|
37
|
+
This information will help us triage your report more quickly.
|
|
38
|
+
|
|
39
|
+
## Policy
|
|
40
|
+
|
|
41
|
+
See
|
|
42
|
+
[GitHub's Safe Harbor Policy](https://docs.github.com/en/site-policy/security-policies/github-bug-bounty-program-legal-safe-harbor#1-safe-harbor-terms)
|
package/SUPPORT.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Support
|
|
2
|
+
|
|
3
|
+
## How to Get Help
|
|
4
|
+
|
|
5
|
+
This project uses GitHub issues to track bugs and feature requests. Please
|
|
6
|
+
search the existing issues before filing new issues to avoid duplicates. For new
|
|
7
|
+
issues, file your bug or feature request as a new issue.
|
|
8
|
+
|
|
9
|
+
For help or questions about using this project, please feel free to submit an
|
|
10
|
+
issue as well.
|
|
11
|
+
|
|
12
|
+
This project is under development and maintained by GitHub staff and the
|
|
13
|
+
community, however availability is limited . We will do our best to respond to
|
|
14
|
+
support, feature requests, and community questions in a timely manner, but there
|
|
15
|
+
is no "official" support for this project at this time.
|
|
16
|
+
|
|
17
|
+
## GitHub Support Policy
|
|
18
|
+
|
|
19
|
+
Support for this project is limited to the resources listed above.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jest } from '@jest/globals'
|
|
2
|
+
|
|
3
|
+
export const debug = jest.fn().mockImplementation(() => {})
|
|
4
|
+
export const error = jest.fn().mockImplementation(() => {})
|
|
5
|
+
export const info = jest.fn().mockImplementation(() => {})
|
|
6
|
+
export const isDebug = jest.fn().mockImplementation(() => false)
|
|
7
|
+
export const getInput = jest.fn().mockImplementation(() => {})
|
|
8
|
+
export const setOutput = jest.fn().mockImplementation(() => {})
|
|
9
|
+
export const setFailed = jest.fn().mockImplementation(() => {})
|
|
10
|
+
export const warning = jest.fn().mockImplementation(() => {})
|
|
11
|
+
export const summary = {
|
|
12
|
+
addRaw: jest.fn().mockImplementation(() => {}),
|
|
13
|
+
write: jest.fn().mockImplementation(() => {})
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jest } from '@jest/globals'
|
|
2
|
+
import { Endpoints } from '@octokit/types'
|
|
3
|
+
|
|
4
|
+
export const graphql = jest.fn()
|
|
5
|
+
export const paginate = jest.fn()
|
|
6
|
+
export const request = jest.fn()
|
|
7
|
+
export const rest = {
|
|
8
|
+
actions: {
|
|
9
|
+
deleteArtifact:
|
|
10
|
+
jest.fn<
|
|
11
|
+
() => Endpoints['DELETE /repos/{owner}/{repo}/actions/artifacts/{artifact_id}']['response']
|
|
12
|
+
>(),
|
|
13
|
+
listWorkflowRunArtifacts:
|
|
14
|
+
jest.fn<
|
|
15
|
+
() => Endpoints['GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts']['response']
|
|
16
|
+
>()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jest } from '@jest/globals'
|
|
2
|
+
|
|
3
|
+
export const accessSync = jest.fn()
|
|
4
|
+
export const copyFileSync = jest.fn()
|
|
5
|
+
export const createWriteStream = jest.fn()
|
|
6
|
+
export const createReadStream = jest.fn()
|
|
7
|
+
export const existsSync = jest.fn()
|
|
8
|
+
export const mkdirSync = jest.fn()
|
|
9
|
+
export const readdirSync = jest.fn()
|
|
10
|
+
export const readFileSync = jest.fn()
|
|
11
|
+
export const rmSync = jest.fn()
|
|
12
|
+
export const statSync = jest.fn()
|
|
13
|
+
export const writeFileSync = jest.fn()
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
accessSync,
|
|
17
|
+
copyFileSync,
|
|
18
|
+
createWriteStream,
|
|
19
|
+
createReadStream,
|
|
20
|
+
existsSync,
|
|
21
|
+
mkdirSync,
|
|
22
|
+
readdirSync,
|
|
23
|
+
readFileSync,
|
|
24
|
+
rmSync,
|
|
25
|
+
statSync,
|
|
26
|
+
writeFileSync
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: JavaScript (No Import)
|
|
2
|
+
description: This action doesn't import any dependencies
|
|
3
|
+
|
|
4
|
+
inputs:
|
|
5
|
+
myInput:
|
|
6
|
+
description: An input
|
|
7
|
+
required: true
|
|
8
|
+
default: value
|
|
9
|
+
|
|
10
|
+
outputs:
|
|
11
|
+
myOutput:
|
|
12
|
+
description: An output
|
|
13
|
+
|
|
14
|
+
runs:
|
|
15
|
+
using: node20
|
|
16
|
+
main: dist/index.js
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: JavaScript (No Import)
|
|
2
|
+
description: This action doesn't import any dependencies
|
|
3
|
+
|
|
4
|
+
inputs:
|
|
5
|
+
myInput:
|
|
6
|
+
description: An input
|
|
7
|
+
required: true
|
|
8
|
+
default: value
|
|
9
|
+
|
|
10
|
+
outputs:
|
|
11
|
+
myOutput:
|
|
12
|
+
description: An output
|
|
13
|
+
|
|
14
|
+
runs:
|
|
15
|
+
using: node20
|
|
16
|
+
main: dist/index.js
|