mirror of
https://github.com/actions/javascript-action.git
synced 2025-12-10 20:56:57 +00:00
Compare commits
17 Commits
081afb2a04
...
v1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41775a4da8 | ||
|
|
c86eae35de | ||
|
|
217981eefd | ||
|
|
956fe516f6 | ||
|
|
78a7f923af | ||
|
|
a8cdc1836c | ||
|
|
1e4f2e2fe0 | ||
|
|
a00bde574e | ||
|
|
4dd109d749 | ||
|
|
9f8d83aafd | ||
|
|
f2f2c6b544 | ||
|
|
85c0aa0036 | ||
|
|
61590a9541 | ||
|
|
b492d32107 | ||
|
|
02e15e8a5a | ||
|
|
73b9a57e3c | ||
|
|
8712ed4eeb |
@@ -1,7 +0,0 @@
|
||||
# See: https://www.checkov.io/1.Welcome/Quick%20Start.html
|
||||
|
||||
compact: true
|
||||
quiet: true
|
||||
skip-path:
|
||||
- coverage
|
||||
- node_modules
|
||||
@@ -1,41 +0,0 @@
|
||||
{
|
||||
"name": "GitHub Actions (JavaScript)",
|
||||
"image": "mcr.microsoft.com/devcontainers/javascript-node:20",
|
||||
"postCreateCommand": "npm install",
|
||||
"customizations": {
|
||||
"codespaces": {
|
||||
"openFiles": ["README.md"]
|
||||
},
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"bierner.markdown-preview-github-styles",
|
||||
"davidanson.vscode-markdownlint",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"github.copilot",
|
||||
"github.copilot-chat",
|
||||
"github.vscode-github-actions",
|
||||
"github.vscode-pull-request-github",
|
||||
"me-dutour-mathieu.vscode-github-actions",
|
||||
"redhat.vscode-yaml",
|
||||
"rvest.vs-code-prettier-eslint",
|
||||
"yzhang.markdown-all-in-one"
|
||||
],
|
||||
"settings": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.tabSize": 2,
|
||||
"editor.formatOnSave": true,
|
||||
"markdown.extension.list.indentationSize": "adaptive",
|
||||
"markdown.extension.italic.indicator": "_",
|
||||
"markdown.extension.orderedList.marker": "one"
|
||||
}
|
||||
}
|
||||
},
|
||||
"remoteEnv": {
|
||||
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
|
||||
},
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/github-cli:1": {},
|
||||
"ghcr.io/devcontainers-community/npm-features/prettier:1": {}
|
||||
}
|
||||
}
|
||||
59
.env.example
59
.env.example
@@ -1,59 +0,0 @@
|
||||
# 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
|
||||
|
||||
# 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=""
|
||||
17
.eslintrc.json
Normal file
17
.eslintrc.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"env": {
|
||||
"commonjs": true,
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018
|
||||
},
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -1,3 +0,0 @@
|
||||
* text=auto eol=lf
|
||||
|
||||
dist/** -diff linguist-generated=true
|
||||
5
.github/codeql/codeql-config.yml
vendored
5
.github/codeql/codeql-config.yml
vendored
@@ -1,5 +0,0 @@
|
||||
name: JavaScript CodeQL Configuration
|
||||
|
||||
paths-ignore:
|
||||
- node_modules
|
||||
- dist
|
||||
127
.github/copilot-instructions.md
vendored
127
.github/copilot-instructions.md
vendored
@@ -1,127 +0,0 @@
|
||||
# Copilot Instructions
|
||||
|
||||
This GitHub Action is written in JavaScript and transpiled to a single file.
|
||||
Both the JavaScript sources and the **generated** JavaScript code are contained
|
||||
in this repository. The JavaScript sources are contained in the `src` directory
|
||||
and the code invoked by GitHub Actions is contained in the `dist` directory. A
|
||||
GitHub Actions workflow checks that the JavaScript code in `dist` is up-to-date.
|
||||
Therefore, you should not review any changes to the contents of the `dist`
|
||||
folder and it is expected that the JavaScript code in `dist` closely mirrors the
|
||||
code it is generated from.
|
||||
|
||||
## Repository Structure
|
||||
|
||||
| Path | Description |
|
||||
| -------------------- | -------------------------------------------------------- |
|
||||
| `__fixtures__/` | Unit Test Fixtures |
|
||||
| `__tests__/` | Unit Tests |
|
||||
| `.devcontainer/` | Development Container Configuration |
|
||||
| `.github/` | GitHub Configuration |
|
||||
| `.licenses/` | License Information |
|
||||
| `.vscode/` | Visual Studio Code Configuration |
|
||||
| `badges/` | Badges for readme |
|
||||
| `dist/` | Generated JavaScript Code |
|
||||
| `src/` | JavaScript Source Code |
|
||||
| `.env.example` | Environment Variables Example for `@github/local-action` |
|
||||
| `.licensed.yml` | Licensed Configuration |
|
||||
| `.markdown-lint.yml` | Markdown Linter Configuration |
|
||||
| `.node-version` | Node.js Version Configuration |
|
||||
| `.prettierrc.yml` | Prettier Formatter Configuration |
|
||||
| `.yaml-lint.yml` | YAML Linter Configuration |
|
||||
| `action.yml` | GitHub Action Metadata |
|
||||
| `CODEOWNERS` | Code Owners File |
|
||||
| `eslint.config.mjs` | ESLint Configuration |
|
||||
| `jest.config.js` | Jest Configuration |
|
||||
| `LICENSE` | License File |
|
||||
| `package.json` | NPM Package Configuration |
|
||||
| `README.md` | Project Documentation |
|
||||
| `rollup.config.js` | Rollup Bundler Configuration |
|
||||
|
||||
## Environment Setup
|
||||
|
||||
Install dependencies by running:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
Ensure all unit tests pass by running:
|
||||
|
||||
```bash
|
||||
npm run test
|
||||
```
|
||||
|
||||
Unit tests should exist in the `__tests__` directory. They are powered by
|
||||
`jest`. Fixtures should be placed in the `__fixtures__` directory.
|
||||
|
||||
## Bundling
|
||||
|
||||
Any time files in the `src` directory are changed, you should run the following
|
||||
command to bundle the JavaScript code into the `dist` directory:
|
||||
|
||||
```bash
|
||||
npm run bundle
|
||||
```
|
||||
|
||||
## General Coding Guidelines
|
||||
|
||||
- Follow standard JavaScript coding conventions and best practices
|
||||
- Changes should maintain consistency with existing patterns and style
|
||||
- Document changes clearly and thoroughly, including updates to existing
|
||||
comments when appropriate
|
||||
- Do not include basic, unnecessary comments that simply restate what the code
|
||||
is doing (focus on explaining _why_, not _what_)
|
||||
- Use consistent error handling patterns throughout the codebase
|
||||
- Keep functions focused and manageable
|
||||
- Use descriptive variable and function names that clearly convey their purpose
|
||||
- Use JSDoc comments to document functions, classes, and complex logic
|
||||
- After doing any refactoring, ensure to run `npm run test` to ensure that all
|
||||
tests still pass and coverage requirements are met
|
||||
- When suggesting code changes, always opt for the most maintainable approach.
|
||||
Try your best to keep the code clean and follow "Don't Repeat Yourself" (DRY)
|
||||
principles
|
||||
- Avoid unnecessary complexity and always consider the long-term maintainability
|
||||
of the code
|
||||
- When writing unit tests, try to consider edge cases as well as the main path
|
||||
of success. This will help ensure that the code is robust and can handle
|
||||
unexpected inputs or situations
|
||||
- Use the `@actions/core` package for logging over `console` to ensure
|
||||
compatibility with GitHub Actions logging features
|
||||
|
||||
### Versioning
|
||||
|
||||
GitHub Actions are versioned using branch and tag names. Please ensure the
|
||||
version in the project's `package.json` is updated to reflect the changes made
|
||||
in the codebase. The version should follow
|
||||
[Semantic Versioning](https://semver.org/) principles.
|
||||
|
||||
## Pull Request Guidelines
|
||||
|
||||
When creating a pull request (PR), please ensure that:
|
||||
|
||||
- Keep changes focused and minimal (avoid large changes, or consider breaking
|
||||
them into separate, smaller PRs)
|
||||
- Formatting checks pass
|
||||
- Linting checks pass
|
||||
- Unit tests pass and coverage requirements are met
|
||||
- The action has been transpiled to JavaScript and the `dist` directory is
|
||||
up-to-date with the latest changes in the `src` directory
|
||||
- If necessary, the `README.md` file is updated to reflect any changes in
|
||||
functionality or usage
|
||||
|
||||
The body of the PR should include:
|
||||
|
||||
- A summary of the changes
|
||||
- A special note of any changes to dependencies
|
||||
- A link to any relevant issues or discussions
|
||||
- Any additional context that may be helpful for reviewers
|
||||
|
||||
## Code Review Guidelines
|
||||
|
||||
When performing a code review, please follow these guidelines:
|
||||
|
||||
- If there are changes that modify the functionality/usage of the action,
|
||||
validate that there are changes in the `README.md` file that document the new
|
||||
or modified functionality
|
||||
26
.github/dependabot.yml
vendored
26
.github/dependabot.yml
vendored
@@ -1,26 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: weekly
|
||||
groups:
|
||||
actions-minor:
|
||||
update-types:
|
||||
- minor
|
||||
- patch
|
||||
|
||||
- package-ecosystem: npm
|
||||
directory: /
|
||||
schedule:
|
||||
interval: weekly
|
||||
groups:
|
||||
npm-development:
|
||||
dependency-type: development
|
||||
update-types:
|
||||
- minor
|
||||
- patch
|
||||
npm-production:
|
||||
dependency-type: production
|
||||
update-types:
|
||||
- patch
|
||||
40
.github/prompts/create-release-notes.prompt.md
vendored
40
.github/prompts/create-release-notes.prompt.md
vendored
@@ -1,40 +0,0 @@
|
||||
---
|
||||
mode: agent
|
||||
tools: ['changes', 'codebase', 'github']
|
||||
description: Generate release notes for updates to the repository.
|
||||
---
|
||||
|
||||
# Create Release Notes
|
||||
|
||||
You are an expert technical writer tasked with creating release notes for
|
||||
updates to this repository. Your specific task is to generate release notes that
|
||||
are clear, concise, and useful for developers and users of the project.
|
||||
|
||||
## Guidelines
|
||||
|
||||
Ensure you adhere to the following guidelines when creating release notes:
|
||||
|
||||
- Use a clear and consistent format for the release notes
|
||||
- Include a summary of the changes made in the release
|
||||
- Highlight any new features, improvements, or bugfixes
|
||||
- If applicable, include instructions for upgrading or migrating to the new
|
||||
version
|
||||
- Use technical language that is appropriate for the audience, but avoid jargon
|
||||
that may not be understood by all users
|
||||
- Ensure that the release notes are easy to read and navigate
|
||||
- Include relevant issue or PR numbers where applicable
|
||||
- Use proper Markdown formatting
|
||||
- Use code blocks for commands, configuration examples, or code changes
|
||||
- Use note and warning callouts for important information
|
||||
|
||||
## Versioning
|
||||
|
||||
GitHub Actions are versioned using branch and tag names. The version in the
|
||||
project's `package.json` should reflect the changes made in the codebase and
|
||||
follow [Semantic Versioning](https://semver.org/) principles. Depending on the
|
||||
nature of the changes, please make sure to adjust the release notes accordingly:
|
||||
|
||||
- For **major** changes, include a detailed description of the breaking changes
|
||||
and how users can adapt to them
|
||||
- For **minor** changes, highlight new features and improvements
|
||||
- For **patch** changes, focus on bugfixes and minor improvements
|
||||
90
.github/prompts/unit-test.prompt.md
vendored
90
.github/prompts/unit-test.prompt.md
vendored
@@ -1,90 +0,0 @@
|
||||
---
|
||||
mode: agent
|
||||
tools: ['codebase', 'github']
|
||||
description: Generate unit tests for one or more files in the repository.
|
||||
---
|
||||
|
||||
# Create Unit Test(s)
|
||||
|
||||
You are an expert software engineer tasked with creating unit tests for the
|
||||
repository. Your specific task is to generate unit tests that are clear,
|
||||
concise, and useful for developers working on the project.
|
||||
|
||||
## Guidelines
|
||||
|
||||
Ensure you adhere to the following guidelines when creating unit tests:
|
||||
|
||||
- Use a clear and consistent format for the unit tests
|
||||
- Include a summary of the functionality being tested
|
||||
- Use descriptive test names that clearly convey their purpose
|
||||
- Ensure tests cover both the main path of success and edge cases
|
||||
- Use proper assertions to validate the expected outcomes
|
||||
- Use `jest` for writing and running tests
|
||||
- Place unit tests in the `__tests__` directory
|
||||
- Use fixtures for any necessary test data, placed in the `__fixtures__`
|
||||
directory
|
||||
|
||||
## Example
|
||||
|
||||
Use the following as an example of how to structure your unit tests:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* Unit tests for the action's main functionality, src/main.js
|
||||
*/
|
||||
import { jest } from '@jest/globals'
|
||||
import * as core from '../__fixtures__/core.js'
|
||||
import { wait } from '../__fixtures__/wait.js'
|
||||
|
||||
// Mocks should be declared before the module being tested is imported.
|
||||
jest.unstable_mockModule('@actions/core', () => core)
|
||||
jest.unstable_mockModule('../src/wait.js', () => ({ wait }))
|
||||
|
||||
// The module being tested should be imported dynamically. This ensures that the
|
||||
// mocks are used in place of any actual dependencies.
|
||||
const { run } = await import('../src/main.js')
|
||||
|
||||
describe('main.js', () => {
|
||||
beforeEach(() => {
|
||||
// Set the action's inputs as return values from core.getInput().
|
||||
core.getInput.mockImplementation(() => '500')
|
||||
|
||||
// Mock the wait function so that it does not actually wait.
|
||||
wait.mockImplementation(() => Promise.resolve('done!'))
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks()
|
||||
})
|
||||
|
||||
it('Sets the time output', async () => {
|
||||
await run()
|
||||
|
||||
// Verify the time output was set.
|
||||
expect(core.setOutput).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'time',
|
||||
// Simple regex to match a time string in the format HH:MM:SS.
|
||||
expect.stringMatching(/^\d{2}:\d{2}:\d{2}/)
|
||||
)
|
||||
})
|
||||
|
||||
it('Sets a failed status', async () => {
|
||||
// Clear the getInput mock and return an invalid value.
|
||||
core.getInput.mockClear().mockReturnValueOnce('this is not a number')
|
||||
|
||||
// Clear the wait mock and return a rejected promise.
|
||||
wait
|
||||
.mockClear()
|
||||
.mockRejectedValueOnce(new Error('milliseconds is not a number'))
|
||||
|
||||
await run()
|
||||
|
||||
// Verify that the action was marked as failed.
|
||||
expect(core.setFailed).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'milliseconds is not a number'
|
||||
)
|
||||
})
|
||||
})
|
||||
```
|
||||
72
.github/workflows/check-dist.yml
vendored
72
.github/workflows/check-dist.yml
vendored
@@ -1,72 +0,0 @@
|
||||
# In JavaScript actions, `dist/` is a special directory. When you reference
|
||||
# an action with the `uses:` property, `dist/index.js` is the code that will be
|
||||
# run. For this project, the `dist/index.js` file is transpiled from other
|
||||
# source files. This workflow ensures the `dist/` directory contains the
|
||||
# expected transpiled code.
|
||||
#
|
||||
# If this workflow is run from a feature branch, it will act as an additional CI
|
||||
# check and fail if the checked-in `dist/` directory does not match what is
|
||||
# expected from the build.
|
||||
name: Check Transpiled JavaScript
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check-dist:
|
||||
name: Check dist/
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node.js
|
||||
id: setup-node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: npm
|
||||
|
||||
- name: Install Dependencies
|
||||
id: install
|
||||
run: npm ci
|
||||
|
||||
- name: Build dist/ Directory
|
||||
id: build
|
||||
run: npm run bundle
|
||||
|
||||
# This will fail the workflow if the `dist/` directory is different than
|
||||
# expected.
|
||||
- name: Compare Directories
|
||||
id: diff
|
||||
run: |
|
||||
if [ ! -d dist/ ]; then
|
||||
echo "Expected dist/ directory does not exist. See status below:"
|
||||
ls -la ./
|
||||
exit 1
|
||||
fi
|
||||
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
|
||||
echo "Detected uncommitted changes after build. See status below:"
|
||||
git diff --ignore-space-at-eol --text dist/
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If `dist/` was different than expected, upload the expected version as a
|
||||
# workflow artifact.
|
||||
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
|
||||
name: Upload Artifact
|
||||
id: upload
|
||||
uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: dist
|
||||
path: dist/
|
||||
64
.github/workflows/ci.yml
vendored
64
.github/workflows/ci.yml
vendored
@@ -1,64 +0,0 @@
|
||||
name: Continuous Integration
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test-javascript:
|
||||
name: JavaScript Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node.js
|
||||
id: setup-node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: npm
|
||||
|
||||
- name: Install Dependencies
|
||||
id: npm-ci
|
||||
run: npm ci
|
||||
|
||||
- name: Check Format
|
||||
id: npm-format-check
|
||||
run: npm run format:check
|
||||
|
||||
- name: Lint
|
||||
id: npm-lint
|
||||
run: npm run lint
|
||||
|
||||
- name: Test
|
||||
id: npm-ci-test
|
||||
run: npm run ci-test
|
||||
|
||||
test-action:
|
||||
name: GitHub Actions Test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Test Local Action
|
||||
id: test-action
|
||||
uses: ./
|
||||
with:
|
||||
milliseconds: 2000
|
||||
|
||||
- name: Print Output
|
||||
id: output
|
||||
run: echo "${{ steps.test-action.outputs.time }}"
|
||||
49
.github/workflows/codeql-analysis.yml
vendored
49
.github/workflows/codeql-analysis.yml
vendored
@@ -1,49 +0,0 @@
|
||||
name: CodeQL
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
schedule:
|
||||
- cron: '31 7 * * 3'
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
checks: write
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language:
|
||||
- javascript
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Initialize CodeQL
|
||||
id: initialize
|
||||
uses: github/codeql-action/init@v4
|
||||
with:
|
||||
config-file: .github/codeql/codeql-config.yml
|
||||
languages: ${{ matrix.language }}
|
||||
source-root: src
|
||||
|
||||
- name: Autobuild
|
||||
id: autobuild
|
||||
uses: github/codeql-action/autobuild@v4
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
id: analyze
|
||||
uses: github/codeql-action/analyze@v4
|
||||
74
.github/workflows/licensed.yml
vendored
74
.github/workflows/licensed.yml
vendored
@@ -1,74 +0,0 @@
|
||||
# This workflow checks the statuses of cached dependencies used in this action
|
||||
# with the help of the Licensed tool. If any licenses are invalid or missing,
|
||||
# this workflow will fail. See: https://github.com/licensee/licensed
|
||||
|
||||
name: Licensed
|
||||
|
||||
on:
|
||||
# Uncomment the below lines to run this workflow on pull requests and pushes
|
||||
# to the default branch. This is useful for checking licenses before merging
|
||||
# changes into the default branch.
|
||||
# pull_request:
|
||||
# branches:
|
||||
# - main
|
||||
# push:
|
||||
# branches:
|
||||
# - main
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
licensed:
|
||||
name: Check Licenses
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node.js
|
||||
id: setup-node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: npm
|
||||
|
||||
- name: Install Dependencies
|
||||
id: npm-ci
|
||||
run: npm ci
|
||||
|
||||
- name: Setup Ruby
|
||||
id: setup-ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ruby
|
||||
|
||||
- uses: licensee/setup-licensed@v1.3.2
|
||||
with:
|
||||
version: 4.x
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# If this is a workflow_dispatch event, update the cached licenses.
|
||||
- if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
name: Update Licenses
|
||||
id: update-licenses
|
||||
run: licensed cache
|
||||
|
||||
# Then, commit the updated licenses to the repository.
|
||||
- if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
name: Commit Licenses
|
||||
id: commit-licenses
|
||||
run: |
|
||||
git config --local user.email "licensed-ci@users.noreply.github.com"
|
||||
git config --local user.name "licensed-ci"
|
||||
git add .
|
||||
git commit -m "Auto-update license files"
|
||||
git push
|
||||
|
||||
# Last, check the status of the cached licenses.
|
||||
- name: Check Licenses
|
||||
id: check-licenses
|
||||
run: licensed status
|
||||
60
.github/workflows/linter.yml
vendored
60
.github/workflows/linter.yml
vendored
@@ -1,60 +0,0 @@
|
||||
# This workflow will lint the entire codebase using the
|
||||
# `super-linter/super-linter` action.
|
||||
#
|
||||
# For more information, see the super-linter repository:
|
||||
# https://github.com/super-linter/super-linter
|
||||
name: Lint Codebase
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
statuses: write
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint Codebase
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
id: setup-node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: npm
|
||||
|
||||
- name: Install Dependencies
|
||||
id: install
|
||||
run: npm ci
|
||||
|
||||
- name: Lint Codebase
|
||||
id: super-linter
|
||||
uses: super-linter/super-linter/slim@v8
|
||||
env:
|
||||
CHECKOV_FILE_NAME: .checkov.yml
|
||||
DEFAULT_BRANCH: main
|
||||
FILTER_REGEX_EXCLUDE: dist/**/*
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
LINTER_RULES_PATH: .
|
||||
VALIDATE_ALL_CODEBASE: true
|
||||
VALIDATE_BIOME_FORMAT: false
|
||||
VALIDATE_BIOME_LINT: false
|
||||
VALIDATE_GITHUB_ACTIONS_ZIZMOR: false
|
||||
VALIDATE_JAVASCRIPT_ES: false
|
||||
VALIDATE_JSCPD: false
|
||||
VALIDATE_TYPESCRIPT_ES: false
|
||||
VALIDATE_JSON: false
|
||||
19
.github/workflows/test.yml
vendored
Normal file
19
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
name: "test-local"
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 'releases/*'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
- uses: ./
|
||||
with:
|
||||
milliseconds: 1000
|
||||
47
.gitignore
vendored
47
.gitignore
vendored
@@ -1,17 +1,12 @@
|
||||
# Dependency directory
|
||||
node_modules
|
||||
# comment this out distribution branches
|
||||
node_modules/
|
||||
|
||||
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
@@ -24,12 +19,11 @@ lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
@@ -41,15 +35,12 @@ bower_components
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
# Other Dependency directories
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
@@ -67,36 +58,6 @@ typings/
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# OS metadata
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Ignore built ts files
|
||||
__tests__/runner/*
|
||||
|
||||
# IDE files
|
||||
.idea
|
||||
*.code-workspace
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# See: https://github.com/licensee/licensed/blob/main/docs/configuration.md
|
||||
|
||||
sources:
|
||||
npm: true
|
||||
|
||||
allowed:
|
||||
- apache-2.0
|
||||
- bsd-2-clause
|
||||
- bsd-3-clause
|
||||
- isc
|
||||
- mit
|
||||
- cc0-1.0
|
||||
- other
|
||||
|
||||
ignored:
|
||||
npm:
|
||||
# Used by Rollup.js when building in GitHub Actions
|
||||
- '@rollup/rollup-linux-x64-gnu'
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: "@actions/core"
|
||||
version: 1.11.1
|
||||
type: npm
|
||||
summary: Actions core lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE.md
|
||||
text: |-
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: "@actions/exec"
|
||||
version: 1.1.1
|
||||
type: npm
|
||||
summary: Actions exec lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/exec
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE.md
|
||||
text: |-
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
||||
@@ -1,32 +0,0 @@
|
||||
---
|
||||
name: "@actions/http-client"
|
||||
version: 2.2.3
|
||||
type: npm
|
||||
summary: Actions Http Client
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
|
||||
license: other
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: "@actions/io"
|
||||
version: 1.1.3
|
||||
type: npm
|
||||
summary: Actions io lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/io
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE.md
|
||||
text: |-
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
||||
@@ -1,30 +0,0 @@
|
||||
---
|
||||
name: "@fastify/busboy"
|
||||
version: 2.1.1
|
||||
type: npm
|
||||
summary: A streaming parser for HTML form data for node.js
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |-
|
||||
Copyright Brian White. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
notices: []
|
||||
@@ -1,35 +0,0 @@
|
||||
---
|
||||
name: tunnel
|
||||
version: 0.0.6
|
||||
type: npm
|
||||
summary: Node HTTP/HTTPS Agents for tunneling proxies
|
||||
homepage: https://github.com/koichik/node-tunnel/
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Koichi Kobayashi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
- sources: README.md
|
||||
text: Licensed under the [MIT](https://github.com/koichik/node-tunnel/blob/master/LICENSE)
|
||||
license.
|
||||
notices: []
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
name: undici
|
||||
version: 5.28.5
|
||||
type: npm
|
||||
summary: An HTTP/1.1 client, written from scratch for Node.js
|
||||
homepage: https://undici.nodejs.org
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Matteo Collina and Undici contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
- sources: README.md
|
||||
text: MIT
|
||||
notices: []
|
||||
@@ -1,24 +0,0 @@
|
||||
# See: https://github.com/DavidAnson/markdownlint
|
||||
|
||||
# Unordered list style
|
||||
MD004:
|
||||
style: dash
|
||||
|
||||
# Disable line length for tables
|
||||
MD013:
|
||||
tables: false
|
||||
|
||||
# Ordered list item prefix
|
||||
MD029:
|
||||
style: one
|
||||
|
||||
# Spaces after list markers
|
||||
MD030:
|
||||
ul_single: 1
|
||||
ol_single: 1
|
||||
ul_multi: 1
|
||||
ol_multi: 1
|
||||
|
||||
# Code block style
|
||||
MD046:
|
||||
style: fenced
|
||||
@@ -1 +0,0 @@
|
||||
24.4.0
|
||||
@@ -1,5 +0,0 @@
|
||||
.DS_Store
|
||||
.licenses/
|
||||
dist/
|
||||
node_modules/
|
||||
coverage/
|
||||
@@ -1,16 +0,0 @@
|
||||
# See: https://prettier.io/docs/en/configuration
|
||||
|
||||
printWidth: 80
|
||||
tabWidth: 2
|
||||
useTabs: false
|
||||
semi: false
|
||||
singleQuote: true
|
||||
quoteProps: as-needed
|
||||
jsxSingleQuote: false
|
||||
trailingComma: none
|
||||
bracketSpacing: true
|
||||
bracketSameLine: true
|
||||
arrowParens: always
|
||||
proseWrap: always
|
||||
htmlWhitespaceSensitivity: css
|
||||
endOfLine: lf
|
||||
15
.vscode/launch.json
vendored
15
.vscode/launch.json
vendored
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug Action",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "npx",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"args": ["@github/local-action", ".", "src/main.js", ".env"],
|
||||
"console": "integratedTerminal",
|
||||
"skipFiles": ["<node_internals>/**", "node_modules/**"]
|
||||
}
|
||||
]
|
||||
}
|
||||
9
.vscode/mcp.json
vendored
9
.vscode/mcp.json
vendored
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"servers": {
|
||||
"github": {
|
||||
"url": "https://api.githubcopilot.com/mcp/",
|
||||
"type": "http"
|
||||
}
|
||||
},
|
||||
"inputs": []
|
||||
}
|
||||
15
.vscode/settings.json
vendored
15
.vscode/settings.json
vendored
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"github.copilot.chat.reviewSelection.instructions": [
|
||||
{
|
||||
"text": "Review the code changes carefully before accepting them."
|
||||
}
|
||||
],
|
||||
"github.copilot.chat.commitMessageGeneration.instructions": [
|
||||
{
|
||||
"text": "Use conventional commit message format."
|
||||
}
|
||||
],
|
||||
"github.copilot.chat.pullRequestDescriptionGeneration.instructions": [
|
||||
{ "text": "Always include a list of key changes." }
|
||||
]
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
# See: https://yamllint.readthedocs.io/en/stable/
|
||||
|
||||
rules:
|
||||
document-end: disable
|
||||
document-start:
|
||||
level: warning
|
||||
present: false
|
||||
line-length:
|
||||
level: warning
|
||||
max: 80
|
||||
allow-non-breakable-words: true
|
||||
allow-non-breakable-inline-mappings: true
|
||||
ignore:
|
||||
- .licenses/
|
||||
@@ -1,7 +0,0 @@
|
||||
############################################################################
|
||||
# Repository CODEOWNERS #
|
||||
# Order is important! The last matching pattern takes the most precedence. #
|
||||
############################################################################
|
||||
|
||||
# Default owners, unless a later match takes precedence.
|
||||
* @actions/actions-oss-maintainers
|
||||
4
LICENSE
4
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright GitHub
|
||||
Copyright (c) 2019 GitHub Actions
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
SOFTWARE.
|
||||
|
||||
323
README.md
323
README.md
@@ -1,278 +1,117 @@
|
||||
# Create a GitHub Action Using JavaScript
|
||||
|
||||
[](https://github.com/actions/javascript-action/actions/workflows/linter.yml)
|
||||
[](https://github.com/actions/javascript-action/actions/workflows/ci.yml)
|
||||
[](https://github.com/actions/javascript-action/actions/workflows/check-dist.yml)
|
||||
[](https://github.com/actions/javascript-action/actions/workflows/codeql-analysis.yml)
|
||||
[](./badges/coverage.svg)
|
||||
<p align="center">
|
||||
<a href="https://github.com/actions/javascript-action"><img alt="GitHub Actions status" src="https://github.com/actions/javascript-action/workflows/test-local/badge.svg"></a>
|
||||
</p>
|
||||
|
||||
Use this template to bootstrap the creation of a JavaScript action. :rocket:
|
||||
# Create a JavaScript Action
|
||||
|
||||
This template includes compilation support, tests, a validation workflow,
|
||||
publishing, and versioning guidance.
|
||||
Use this template to bootstrap the creation of a JavaScript action.:rocket:
|
||||
|
||||
If you are new, there's also a simpler introduction in the
|
||||
[Hello world JavaScript action repository](https://github.com/actions/hello-world-javascript-action).
|
||||
This template includes tests, linting, a validation workflow, publishing, and versioning guidance.
|
||||
|
||||
## Create Your Own Action
|
||||
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
|
||||
|
||||
To create your own action, you can use this repository as a template! Just
|
||||
follow the below instructions:
|
||||
This walk through takes you through creation, testing and publishing the action.
|
||||
|
||||
1. Click the **Use this template** button at the top of the repository
|
||||
1. Select **Create a new repository**
|
||||
1. Select an owner and name for your new repository
|
||||
1. Click **Create repository**
|
||||
1. Clone your new repository
|
||||
This walk through takes you through creation, testing and publishing the action.
|
||||
|
||||
> [!IMPORTANT]
|
||||
>
|
||||
> Make sure to remove or update the [`CODEOWNERS`](./CODEOWNERS) file! For
|
||||
> details on how to use this file, see
|
||||
> [About code owners](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners).
|
||||
## Create an action from this template
|
||||
|
||||
## Initial Setup
|
||||
Click the `Use this Template` and provide the new repo details for your action
|
||||
|
||||
After you've cloned the repository to your local machine or codespace, you'll
|
||||
need to perform some initial setup steps before you can develop your action.
|
||||
## Code in Master
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> You'll need to have a reasonably modern version of
|
||||
> [Node.js](https://nodejs.org) handy (20.x or later should work!). If you are
|
||||
> using a version manager like [`nodenv`](https://github.com/nodenv/nodenv) or
|
||||
> [`fnm`](https://github.com/Schniz/fnm), this template has a `.node-version`
|
||||
> file at the root of the repository that can be used to automatically switch to
|
||||
> the correct version when you `cd` into the repository. Additionally, this
|
||||
> `.node-version` file is used by GitHub Actions in any `actions/setup-node`
|
||||
> actions.
|
||||
Install the dependencies
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
1. :hammer_and_wrench: Install the dependencies
|
||||
Run the tests :heavy_check_mark:
|
||||
```bash
|
||||
$ npm test
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
PASS ./index.test.js
|
||||
✓ throws invalid number (3ms)
|
||||
✓ wait 500 ms (504ms)
|
||||
✓ test runs (95ms)
|
||||
|
||||
1. :building_construction: Package the JavaScript for distribution
|
||||
...
|
||||
```
|
||||
|
||||
```bash
|
||||
npm run bundle
|
||||
```
|
||||
## Change action.yml
|
||||
|
||||
1. :white_check_mark: Run the tests
|
||||
The action.yml contains defines the inputs and output for your action.
|
||||
|
||||
```bash
|
||||
$ npm test
|
||||
Update the action.yml with your name, description, inputs and outputs for your action.
|
||||
|
||||
PASS ./index.test.js
|
||||
✓ throws invalid number (3ms)
|
||||
✓ wait 500 ms (504ms)
|
||||
✓ test runs (95ms)
|
||||
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
|
||||
|
||||
...
|
||||
```
|
||||
## Change the Code
|
||||
|
||||
## Update the Action Metadata
|
||||
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
|
||||
|
||||
The [`action.yml`](action.yml) file defines metadata about your action, such as
|
||||
input(s) and output(s). For details about this file, see
|
||||
[Metadata syntax for GitHub Actions](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions).
|
||||
```javascript
|
||||
const core = require('@actions/core');
|
||||
...
|
||||
|
||||
When you copy this repository, update `action.yml` with the name, description,
|
||||
inputs, and outputs for your action.
|
||||
|
||||
## Update the Action Code
|
||||
|
||||
The [`src/`](./src/) directory is the heart of your action! This contains the
|
||||
source code that will be run when your action is invoked. You can replace the
|
||||
contents of this directory with your own code.
|
||||
|
||||
There are a few things to keep in mind when writing your action code:
|
||||
|
||||
- Most GitHub Actions toolkit and CI/CD operations are processed asynchronously.
|
||||
In `main.js`, you will see that the action is run in an `async` function.
|
||||
|
||||
```javascript
|
||||
const core = require('@actions/core')
|
||||
//...
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
//...
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
async function run() {
|
||||
try {
|
||||
...
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
```
|
||||
}
|
||||
|
||||
For more information about the GitHub Actions toolkit, see the
|
||||
[documentation](https://github.com/actions/toolkit/blob/main/README.md).
|
||||
|
||||
So, what are you waiting for? Go ahead and start customizing your action!
|
||||
|
||||
1. Create a new branch
|
||||
|
||||
```bash
|
||||
git checkout -b releases/v1
|
||||
```
|
||||
|
||||
1. Replace the contents of `src/` with your action code
|
||||
1. Add tests to `__tests__/` for your source code
|
||||
1. Format, test, and build the action
|
||||
|
||||
```bash
|
||||
npm run all
|
||||
```
|
||||
|
||||
> This step is important! It will run [`rollup`](https://rollupjs.org/) to
|
||||
> build the final JavaScript action code with all dependencies included. If
|
||||
> you do not run this step, your action will not work correctly when it is
|
||||
> used in a workflow.
|
||||
|
||||
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 @github/local action <action-yaml-path> <entrypoint> <dotenv-file>
|
||||
npx @github/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
|
||||
git add .
|
||||
git commit -m "My first action is ready!"
|
||||
```
|
||||
|
||||
1. Push them to your repository
|
||||
|
||||
```bash
|
||||
git push -u origin releases/v1
|
||||
```
|
||||
|
||||
1. Create a pull request and get feedback on your action
|
||||
1. Merge the pull request into the `main` branch
|
||||
|
||||
Your action is now published! :rocket:
|
||||
|
||||
For information about versioning your action, see
|
||||
[Versioning](https://github.com/actions/toolkit/blob/main/docs/action-versioning.md)
|
||||
in the GitHub Actions toolkit.
|
||||
|
||||
## Validate the Action
|
||||
|
||||
You can now validate the action by referencing it in a workflow file. For
|
||||
example, [`ci.yml`](./.github/workflows/ci.yml) demonstrates how to reference an
|
||||
action in the same repository.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Test Local Action
|
||||
id: test-action
|
||||
uses: ./
|
||||
with:
|
||||
milliseconds: 1000
|
||||
|
||||
- name: Print Output
|
||||
id: output
|
||||
run: echo "${{ steps.test-action.outputs.time }}"
|
||||
run()
|
||||
```
|
||||
|
||||
For example workflow runs, check out the
|
||||
[Actions tab](https://github.com/actions/javascript-action/actions)! :rocket:
|
||||
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
|
||||
|
||||
## Usage
|
||||
## Publish to a distribution branch
|
||||
|
||||
After testing, you can create version tag(s) that developers can use to
|
||||
reference different stable versions of your action. For more information, see
|
||||
[Versioning](https://github.com/actions/toolkit/blob/main/docs/action-versioning.md)
|
||||
in the GitHub Actions toolkit.
|
||||
Actions are run from GitHub repos. We will create a releases branch and only checkin production modules (core in this case).
|
||||
|
||||
To include the action in a workflow in another repository, you can use the
|
||||
`uses` syntax with the `@` symbol to reference a specific branch, tag, or commit
|
||||
hash.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Test Local Action
|
||||
id: test-action
|
||||
uses: actions/javascript-action@v1 # Commit with the `v1` tag
|
||||
with:
|
||||
milliseconds: 1000
|
||||
|
||||
- name: Print Output
|
||||
id: output
|
||||
run: echo "${{ steps.test-action.outputs.time }}"
|
||||
Comment out node_modules in .gitignore and create a releases/v1 branch
|
||||
```bash
|
||||
# comment this out distribution branches
|
||||
# node_modules/
|
||||
```
|
||||
|
||||
## Dependency License Management
|
||||
|
||||
This template includes a GitHub Actions workflow,
|
||||
[`licensed.yml`](./.github/workflows/licensed.yml), that uses
|
||||
[Licensed](https://github.com/licensee/licensed) to check for dependencies with
|
||||
missing or non-compliant licenses. This workflow is initially disabled. To
|
||||
enable the workflow, follow the below steps.
|
||||
|
||||
1. Open [`licensed.yml`](./.github/workflows/licensed.yml)
|
||||
1. Uncomment the following lines:
|
||||
|
||||
```yaml
|
||||
# pull_request:
|
||||
# branches:
|
||||
# - main
|
||||
# push:
|
||||
# branches:
|
||||
# - main
|
||||
```
|
||||
|
||||
1. Save and commit the changes
|
||||
|
||||
Once complete, this workflow will run any time a pull request is created or
|
||||
changes pushed directly to `main`. If the workflow detects any dependencies with
|
||||
missing or non-compliant licenses, it will fail the workflow and provide details
|
||||
on the issue(s) found.
|
||||
|
||||
### Updating Licenses
|
||||
|
||||
Whenever you install or update dependencies, you can use the Licensed CLI to
|
||||
update the licenses database. To install Licensed, see the project's
|
||||
[Readme](https://github.com/licensee/licensed?tab=readme-ov-file#installation).
|
||||
|
||||
To update the cached licenses, run the following command:
|
||||
|
||||
```bash
|
||||
licensed cache
|
||||
$ git checkout -b releases/v1
|
||||
$ git commit -a -m "prod dependencies"
|
||||
```
|
||||
|
||||
To check the status of cached licenses, run the following command:
|
||||
|
||||
```bash
|
||||
licensed status
|
||||
$ npm prune --production
|
||||
$ git add node_modules
|
||||
$ git commit -a -m "prod dependencies"
|
||||
$ git push origin releases/v1
|
||||
```
|
||||
|
||||
Your action is now published! :rocket:
|
||||
|
||||
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
|
||||
|
||||
## Validate
|
||||
|
||||
You can now validate the action by referencing the releases/v1 branch
|
||||
|
||||
```yaml
|
||||
uses: actions/javascript-action@releases/v1
|
||||
with:
|
||||
milliseconds: 1000
|
||||
```
|
||||
|
||||
See the [actions tab](https://github.com/actions/javascript-action/actions) for runs of this action! :rocket:
|
||||
|
||||
## Usage:
|
||||
|
||||
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and tested action
|
||||
|
||||
```yaml
|
||||
uses: actions/javascript-action@v1
|
||||
with:
|
||||
milliseconds: 1000
|
||||
```
|
||||
@@ -1,12 +0,0 @@
|
||||
/**
|
||||
* This file is used to mock the `@actions/core` module in tests.
|
||||
*/
|
||||
import { jest } from '@jest/globals'
|
||||
|
||||
export const debug = jest.fn()
|
||||
export const error = jest.fn()
|
||||
export const info = jest.fn()
|
||||
export const getInput = jest.fn()
|
||||
export const setOutput = jest.fn()
|
||||
export const setFailed = jest.fn()
|
||||
export const warning = jest.fn()
|
||||
@@ -1,3 +0,0 @@
|
||||
import { jest } from '@jest/globals'
|
||||
|
||||
export const wait = jest.fn()
|
||||
@@ -1,62 +0,0 @@
|
||||
/**
|
||||
* Unit tests for the action's main functionality, src/main.js
|
||||
*
|
||||
* To mock dependencies in ESM, you can create fixtures that export mock
|
||||
* functions and objects. For example, the core module is mocked in this test,
|
||||
* so that the actual '@actions/core' module is not imported.
|
||||
*/
|
||||
import { jest } from '@jest/globals'
|
||||
import * as core from '../__fixtures__/core.js'
|
||||
import { wait } from '../__fixtures__/wait.js'
|
||||
|
||||
// Mocks should be declared before the module being tested is imported.
|
||||
jest.unstable_mockModule('@actions/core', () => core)
|
||||
jest.unstable_mockModule('../src/wait.js', () => ({ wait }))
|
||||
|
||||
// The module being tested should be imported dynamically. This ensures that the
|
||||
// mocks are used in place of any actual dependencies.
|
||||
const { run } = await import('../src/main.js')
|
||||
|
||||
describe('main.js', () => {
|
||||
beforeEach(() => {
|
||||
// Set the action's inputs as return values from core.getInput().
|
||||
core.getInput.mockImplementation(() => '500')
|
||||
|
||||
// Mock the wait function so that it does not actually wait.
|
||||
wait.mockImplementation(() => Promise.resolve('done!'))
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks()
|
||||
})
|
||||
|
||||
it('Sets the time output', async () => {
|
||||
await run()
|
||||
|
||||
// Verify the time output was set.
|
||||
expect(core.setOutput).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'time',
|
||||
// Simple regex to match a time string in the format HH:MM:SS.
|
||||
expect.stringMatching(/^\d{2}:\d{2}:\d{2}/)
|
||||
)
|
||||
})
|
||||
|
||||
it('Sets a failed status', async () => {
|
||||
// Clear the getInput mock and return an invalid value.
|
||||
core.getInput.mockClear().mockReturnValueOnce('this is not a number')
|
||||
|
||||
// Clear the wait mock and return a rejected promise.
|
||||
wait
|
||||
.mockClear()
|
||||
.mockRejectedValueOnce(new Error('milliseconds is not a number'))
|
||||
|
||||
await run()
|
||||
|
||||
// Verify that the action was marked as failed.
|
||||
expect(core.setFailed).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'milliseconds is not a number'
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -1,24 +0,0 @@
|
||||
/**
|
||||
* Unit tests for src/wait.js
|
||||
*/
|
||||
import { wait } from '../src/wait.js'
|
||||
|
||||
describe('wait.js', () => {
|
||||
it('Throws an invalid number', async () => {
|
||||
const input = parseInt('foo', 10)
|
||||
|
||||
expect(isNaN(input)).toBe(true)
|
||||
|
||||
await expect(wait(input)).rejects.toThrow('milliseconds is not a number')
|
||||
})
|
||||
|
||||
it('Waits with a valid number', async () => {
|
||||
const start = new Date()
|
||||
await wait(500)
|
||||
const end = new Date()
|
||||
|
||||
const delta = Math.abs(end.getTime() - start.getTime())
|
||||
|
||||
expect(delta).toBeGreaterThan(450)
|
||||
})
|
||||
})
|
||||
27
action.yml
27
action.yml
@@ -1,24 +1,13 @@
|
||||
name: The name of your action here
|
||||
description: Provide a description here
|
||||
author: Your name or organization here
|
||||
|
||||
# Add your action's branding here. This will appear on the GitHub Marketplace.
|
||||
branding:
|
||||
icon: heart
|
||||
color: red
|
||||
|
||||
# Define your inputs here.
|
||||
name: 'Wait'
|
||||
description: 'Wait a designated number of milliseconds'
|
||||
inputs:
|
||||
milliseconds:
|
||||
description: Your input description here
|
||||
milliseconds: # id of input
|
||||
description: 'number of milliseconds to wait'
|
||||
required: true
|
||||
default: '1000'
|
||||
|
||||
# Define your outputs here.
|
||||
outputs:
|
||||
time:
|
||||
description: Your output description here
|
||||
|
||||
time: # output will be available to future steps
|
||||
description: 'The message to output'
|
||||
runs:
|
||||
using: node24
|
||||
main: dist/index.js
|
||||
using: 'node12'
|
||||
main: 'index.js'
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
# See: https://github.com/rhysd/actionlint/blob/v1.7.7/docs/config.md
|
||||
|
||||
paths:
|
||||
.github/workflows/**/*.{yml,yaml}:
|
||||
ignore:
|
||||
- invalid runner name "node24"
|
||||
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="106" height="20" role="img" aria-label="Coverage: 100%"><title>Coverage: 100%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="106" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="43" height="20" fill="#4c1"/><rect width="106" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="835" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="330">100%</text><text x="835" y="140" transform="scale(.1)" fill="#fff" textLength="330">100%</text></g></svg>
|
||||
|
Before Width: | Height: | Size: 1.1 KiB |
27302
dist/index.js
vendored
27302
dist/index.js
vendored
File diff suppressed because one or more lines are too long
1
dist/index.js.map
vendored
1
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -1,61 +0,0 @@
|
||||
// See: https://eslint.org/docs/latest/use/configure/configuration-files
|
||||
|
||||
import { fixupPluginRules } from '@eslint/compat'
|
||||
import { FlatCompat } from '@eslint/eslintrc'
|
||||
import js from '@eslint/js'
|
||||
import _import from 'eslint-plugin-import'
|
||||
import jest from 'eslint-plugin-jest'
|
||||
import prettier from 'eslint-plugin-prettier'
|
||||
import globals from 'globals'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = path.dirname(__filename)
|
||||
const compat = new FlatCompat({
|
||||
baseDirectory: __dirname,
|
||||
recommendedConfig: js.configs.recommended,
|
||||
allConfig: js.configs.all
|
||||
})
|
||||
|
||||
export default [
|
||||
{
|
||||
ignores: ['**/coverage', '**/dist', '**/linter', '**/node_modules']
|
||||
},
|
||||
...compat.extends(
|
||||
'eslint:recommended',
|
||||
'plugin:jest/recommended',
|
||||
'plugin:prettier/recommended'
|
||||
),
|
||||
{
|
||||
plugins: {
|
||||
import: fixupPluginRules(_import),
|
||||
jest,
|
||||
prettier
|
||||
},
|
||||
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.jest,
|
||||
Atomics: 'readonly',
|
||||
SharedArrayBuffer: 'readonly'
|
||||
},
|
||||
|
||||
ecmaVersion: 2023,
|
||||
sourceType: 'module'
|
||||
},
|
||||
|
||||
rules: {
|
||||
camelcase: 'off',
|
||||
'eslint-comments/no-use': 'off',
|
||||
'eslint-comments/no-unused-disable': 'off',
|
||||
'i18n-text/no-en': 'off',
|
||||
'import/no-namespace': 'off',
|
||||
'no-console': 'off',
|
||||
'no-shadow': 'off',
|
||||
'no-unused-vars': 'off',
|
||||
'prettier/prettier': 'error'
|
||||
}
|
||||
}
|
||||
]
|
||||
22
index.js
Normal file
22
index.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const core = require('@actions/core');
|
||||
const wait = require('./wait');
|
||||
|
||||
|
||||
// most @actions toolkit packages have async methods
|
||||
async function run() {
|
||||
try {
|
||||
const ms = core.getInput('milliseconds');
|
||||
console.log(`Waiting ${ms} milliseconds ...`)
|
||||
|
||||
core.debug((new Date()).toTimeString())
|
||||
wait(parseInt(ms));
|
||||
core.debug((new Date()).toTimeString())
|
||||
|
||||
core.setOutput('time', new Date().toTimeString());
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
run()
|
||||
23
index.test.js
Normal file
23
index.test.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const wait = require('./wait');
|
||||
const process = require('process');
|
||||
const cp = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
test('throws invalid number', async() => {
|
||||
await expect(wait('foo')).rejects.toThrow('milleseconds not a number');
|
||||
});
|
||||
|
||||
test('wait 500 ms', async() => {
|
||||
const start = new Date();
|
||||
await wait(500);
|
||||
const end = new Date();
|
||||
var delta = Math.abs(end - start);
|
||||
expect(delta).toBeGreaterThan(450);
|
||||
});
|
||||
|
||||
// shows how the runner will run a javascript action with env / stdout protocol
|
||||
test('test runs', () => {
|
||||
process.env['INPUT_MILLISECONDS'] = 500;
|
||||
const ip = path.join(__dirname, 'index.js');
|
||||
console.log(cp.execSync(`node ${ip}`).toString());
|
||||
})
|
||||
@@ -1,30 +0,0 @@
|
||||
// See: https://jestjs.io/docs/configuration
|
||||
|
||||
/** @type {import('jest').Config} */
|
||||
const jestConfig = {
|
||||
clearMocks: true,
|
||||
collectCoverage: true,
|
||||
collectCoverageFrom: ['./src/**'],
|
||||
coverageDirectory: './coverage',
|
||||
coveragePathIgnorePatterns: ['/node_modules/', '/dist/'],
|
||||
coverageReporters: ['json-summary', 'text', 'lcov'],
|
||||
// Uncomment the below lines if you would like to enforce a coverage threshold
|
||||
// for your action. This will fail the build if the coverage is below the
|
||||
// specified thresholds.
|
||||
// coverageThreshold: {
|
||||
// global: {
|
||||
// branches: 100,
|
||||
// functions: 100,
|
||||
// lines: 100,
|
||||
// statements: 100
|
||||
// }
|
||||
// },
|
||||
moduleFileExtensions: ['js'],
|
||||
reporters: ['default'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.js'],
|
||||
testPathIgnorePatterns: ['/dist/', '/node_modules/'],
|
||||
verbose: true
|
||||
}
|
||||
|
||||
export default jestConfig
|
||||
97
node_modules/@actions/core/README.md
generated
vendored
Normal file
97
node_modules/@actions/core/README.md
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
# `@actions/core`
|
||||
|
||||
> Core functions for setting results, logging, registering secrets and exporting variables across actions
|
||||
|
||||
## Usage
|
||||
|
||||
#### Inputs/Outputs
|
||||
|
||||
You can use this library to get inputs or set outputs:
|
||||
|
||||
```js
|
||||
const core = require('@actions/core');
|
||||
|
||||
const myInput = core.getInput('inputName', { required: true });
|
||||
|
||||
// Do stuff
|
||||
|
||||
core.setOutput('outputKey', 'outputVal');
|
||||
```
|
||||
|
||||
#### Exporting variables
|
||||
|
||||
You can also export variables for future steps. Variables get set in the environment.
|
||||
|
||||
```js
|
||||
const core = require('@actions/core');
|
||||
|
||||
// Do stuff
|
||||
|
||||
core.exportVariable('envVar', 'Val');
|
||||
```
|
||||
|
||||
#### PATH Manipulation
|
||||
|
||||
You can explicitly add items to the path for all remaining steps in a workflow:
|
||||
|
||||
```js
|
||||
const core = require('@actions/core');
|
||||
|
||||
core.addPath('pathToTool');
|
||||
```
|
||||
|
||||
#### Exit codes
|
||||
|
||||
You should use this library to set the failing exit code for your action:
|
||||
|
||||
```js
|
||||
const core = require('@actions/core');
|
||||
|
||||
try {
|
||||
// Do stuff
|
||||
}
|
||||
catch (err) {
|
||||
// setFailed logs the message and sets a failing exit code
|
||||
core.setFailed(`Action failed with error ${err}`);
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
#### Logging
|
||||
|
||||
Finally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs).
|
||||
|
||||
```js
|
||||
const core = require('@actions/core');
|
||||
|
||||
const myInput = core.getInput('input');
|
||||
try {
|
||||
core.debug('Inside try block');
|
||||
|
||||
if (!myInput) {
|
||||
core.warning('myInput was not set');
|
||||
}
|
||||
|
||||
// Do stuff
|
||||
}
|
||||
catch (err) {
|
||||
core.error(`Error ${err}, action may still succeed though`);
|
||||
}
|
||||
```
|
||||
|
||||
This library can also wrap chunks of output in foldable groups.
|
||||
|
||||
```js
|
||||
const core = require('@actions/core')
|
||||
|
||||
// Manually wrap output
|
||||
core.startGroup('Do some function')
|
||||
doSomeFunction()
|
||||
core.endGroup()
|
||||
|
||||
// Wrap an asynchronous function call
|
||||
const result = await core.group('Do something async', async () => {
|
||||
const response = await doSomeHTTPRequest()
|
||||
return response
|
||||
})
|
||||
```
|
||||
16
node_modules/@actions/core/lib/command.d.ts
generated
vendored
Normal file
16
node_modules/@actions/core/lib/command.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
interface CommandProperties {
|
||||
[key: string]: string;
|
||||
}
|
||||
/**
|
||||
* Commands
|
||||
*
|
||||
* Command Format:
|
||||
* ##[name key=value;key=value]message
|
||||
*
|
||||
* Examples:
|
||||
* ##[warning]This is the user warning message
|
||||
* ##[set-secret name=mypassword]definitelyNotAPassword!
|
||||
*/
|
||||
export declare function issueCommand(command: string, properties: CommandProperties, message: string): void;
|
||||
export declare function issue(name: string, message?: string): void;
|
||||
export {};
|
||||
66
node_modules/@actions/core/lib/command.js
generated
vendored
Normal file
66
node_modules/@actions/core/lib/command.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const os = require("os");
|
||||
/**
|
||||
* Commands
|
||||
*
|
||||
* Command Format:
|
||||
* ##[name key=value;key=value]message
|
||||
*
|
||||
* Examples:
|
||||
* ##[warning]This is the user warning message
|
||||
* ##[set-secret name=mypassword]definitelyNotAPassword!
|
||||
*/
|
||||
function issueCommand(command, properties, message) {
|
||||
const cmd = new Command(command, properties, message);
|
||||
process.stdout.write(cmd.toString() + os.EOL);
|
||||
}
|
||||
exports.issueCommand = issueCommand;
|
||||
function issue(name, message = '') {
|
||||
issueCommand(name, {}, message);
|
||||
}
|
||||
exports.issue = issue;
|
||||
const CMD_STRING = '::';
|
||||
class Command {
|
||||
constructor(command, properties, message) {
|
||||
if (!command) {
|
||||
command = 'missing.command';
|
||||
}
|
||||
this.command = command;
|
||||
this.properties = properties;
|
||||
this.message = message;
|
||||
}
|
||||
toString() {
|
||||
let cmdStr = CMD_STRING + this.command;
|
||||
if (this.properties && Object.keys(this.properties).length > 0) {
|
||||
cmdStr += ' ';
|
||||
for (const key in this.properties) {
|
||||
if (this.properties.hasOwnProperty(key)) {
|
||||
const val = this.properties[key];
|
||||
if (val) {
|
||||
// safely append the val - avoid blowing up when attempting to
|
||||
// call .replace() if message is not a string for some reason
|
||||
cmdStr += `${key}=${escape(`${val || ''}`)},`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cmdStr += CMD_STRING;
|
||||
// safely append the message - avoid blowing up when attempting to
|
||||
// call .replace() if message is not a string for some reason
|
||||
const message = `${this.message || ''}`;
|
||||
cmdStr += escapeData(message);
|
||||
return cmdStr;
|
||||
}
|
||||
}
|
||||
function escapeData(s) {
|
||||
return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A');
|
||||
}
|
||||
function escape(s) {
|
||||
return s
|
||||
.replace(/\r/g, '%0D')
|
||||
.replace(/\n/g, '%0A')
|
||||
.replace(/]/g, '%5D')
|
||||
.replace(/;/g, '%3B');
|
||||
}
|
||||
//# sourceMappingURL=command.js.map
|
||||
1
node_modules/@actions/core/lib/command.js.map
generated
vendored
Normal file
1
node_modules/@actions/core/lib/command.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,UAAkB,EAAE;IACtD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,IAAI,CAAA;AAEvB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,OAAO,CAAA;QAEtC,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9D,MAAM,IAAI,GAAG,CAAA;YACb,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjC,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;oBACvC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;oBAChC,IAAI,GAAG,EAAE;wBACP,8DAA8D;wBAC9D,6DAA6D;wBAC7D,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAA;qBAC9C;iBACF;aACF;SACF;QAED,MAAM,IAAI,UAAU,CAAA;QAEpB,kEAAkE;QAClE,6DAA6D;QAC7D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;QACvC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC;SACL,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}
|
||||
99
node_modules/@actions/core/lib/core.d.ts
generated
vendored
Normal file
99
node_modules/@actions/core/lib/core.d.ts
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* Interface for getInput options
|
||||
*/
|
||||
export interface InputOptions {
|
||||
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
||||
required?: boolean;
|
||||
}
|
||||
/**
|
||||
* The code to exit an action
|
||||
*/
|
||||
export declare enum ExitCode {
|
||||
/**
|
||||
* A code indicating that the action was successful
|
||||
*/
|
||||
Success = 0,
|
||||
/**
|
||||
* A code indicating that the action was a failure
|
||||
*/
|
||||
Failure = 1
|
||||
}
|
||||
/**
|
||||
* sets env variable for this action and future actions in the job
|
||||
* @param name the name of the variable to set
|
||||
* @param val the value of the variable
|
||||
*/
|
||||
export declare function exportVariable(name: string, val: string): void;
|
||||
/**
|
||||
* exports the variable and registers a secret which will get masked from logs
|
||||
* @param name the name of the variable to set
|
||||
* @param val value of the secret
|
||||
*/
|
||||
export declare function exportSecret(name: string, val: string): void;
|
||||
/**
|
||||
* Prepends inputPath to the PATH (for this action and future actions)
|
||||
* @param inputPath
|
||||
*/
|
||||
export declare function addPath(inputPath: string): void;
|
||||
/**
|
||||
* Gets the value of an input. The value is also trimmed.
|
||||
*
|
||||
* @param name name of the input to get
|
||||
* @param options optional. See InputOptions.
|
||||
* @returns string
|
||||
*/
|
||||
export declare function getInput(name: string, options?: InputOptions): string;
|
||||
/**
|
||||
* Sets the value of an output.
|
||||
*
|
||||
* @param name name of the output to set
|
||||
* @param value value to store
|
||||
*/
|
||||
export declare function setOutput(name: string, value: string): void;
|
||||
/**
|
||||
* Sets the action status to failed.
|
||||
* When the action exits it will be with an exit code of 1
|
||||
* @param message add error issue message
|
||||
*/
|
||||
export declare function setFailed(message: string): void;
|
||||
/**
|
||||
* Writes debug message to user log
|
||||
* @param message debug message
|
||||
*/
|
||||
export declare function debug(message: string): void;
|
||||
/**
|
||||
* Adds an error issue
|
||||
* @param message error issue message
|
||||
*/
|
||||
export declare function error(message: string): void;
|
||||
/**
|
||||
* Adds an warning issue
|
||||
* @param message warning issue message
|
||||
*/
|
||||
export declare function warning(message: string): void;
|
||||
/**
|
||||
* Writes info to log with console.log.
|
||||
* @param message info message
|
||||
*/
|
||||
export declare function info(message: string): void;
|
||||
/**
|
||||
* Begin an output group.
|
||||
*
|
||||
* Output until the next `groupEnd` will be foldable in this group
|
||||
*
|
||||
* @param name The name of the output group
|
||||
*/
|
||||
export declare function startGroup(name: string): void;
|
||||
/**
|
||||
* End an output group.
|
||||
*/
|
||||
export declare function endGroup(): void;
|
||||
/**
|
||||
* Wrap an asynchronous function call in a group.
|
||||
*
|
||||
* Returns the same type as the function itself.
|
||||
*
|
||||
* @param name The name of the group
|
||||
* @param fn The function to wrap in the group
|
||||
*/
|
||||
export declare function group<T>(name: string, fn: () => Promise<T>): Promise<T>;
|
||||
177
node_modules/@actions/core/lib/core.js
generated
vendored
Normal file
177
node_modules/@actions/core/lib/core.js
generated
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const command_1 = require("./command");
|
||||
const os = require("os");
|
||||
const path = require("path");
|
||||
/**
|
||||
* The code to exit an action
|
||||
*/
|
||||
var ExitCode;
|
||||
(function (ExitCode) {
|
||||
/**
|
||||
* A code indicating that the action was successful
|
||||
*/
|
||||
ExitCode[ExitCode["Success"] = 0] = "Success";
|
||||
/**
|
||||
* A code indicating that the action was a failure
|
||||
*/
|
||||
ExitCode[ExitCode["Failure"] = 1] = "Failure";
|
||||
})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
|
||||
//-----------------------------------------------------------------------
|
||||
// Variables
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* sets env variable for this action and future actions in the job
|
||||
* @param name the name of the variable to set
|
||||
* @param val the value of the variable
|
||||
*/
|
||||
function exportVariable(name, val) {
|
||||
process.env[name] = val;
|
||||
command_1.issueCommand('set-env', { name }, val);
|
||||
}
|
||||
exports.exportVariable = exportVariable;
|
||||
/**
|
||||
* exports the variable and registers a secret which will get masked from logs
|
||||
* @param name the name of the variable to set
|
||||
* @param val value of the secret
|
||||
*/
|
||||
function exportSecret(name, val) {
|
||||
exportVariable(name, val);
|
||||
// the runner will error with not implemented
|
||||
// leaving the function but raising the error earlier
|
||||
command_1.issueCommand('set-secret', {}, val);
|
||||
throw new Error('Not implemented.');
|
||||
}
|
||||
exports.exportSecret = exportSecret;
|
||||
/**
|
||||
* Prepends inputPath to the PATH (for this action and future actions)
|
||||
* @param inputPath
|
||||
*/
|
||||
function addPath(inputPath) {
|
||||
command_1.issueCommand('add-path', {}, inputPath);
|
||||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
||||
}
|
||||
exports.addPath = addPath;
|
||||
/**
|
||||
* Gets the value of an input. The value is also trimmed.
|
||||
*
|
||||
* @param name name of the input to get
|
||||
* @param options optional. See InputOptions.
|
||||
* @returns string
|
||||
*/
|
||||
function getInput(name, options) {
|
||||
const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
|
||||
if (options && options.required && !val) {
|
||||
throw new Error(`Input required and not supplied: ${name}`);
|
||||
}
|
||||
return val.trim();
|
||||
}
|
||||
exports.getInput = getInput;
|
||||
/**
|
||||
* Sets the value of an output.
|
||||
*
|
||||
* @param name name of the output to set
|
||||
* @param value value to store
|
||||
*/
|
||||
function setOutput(name, value) {
|
||||
command_1.issueCommand('set-output', { name }, value);
|
||||
}
|
||||
exports.setOutput = setOutput;
|
||||
//-----------------------------------------------------------------------
|
||||
// Results
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Sets the action status to failed.
|
||||
* When the action exits it will be with an exit code of 1
|
||||
* @param message add error issue message
|
||||
*/
|
||||
function setFailed(message) {
|
||||
process.exitCode = ExitCode.Failure;
|
||||
error(message);
|
||||
}
|
||||
exports.setFailed = setFailed;
|
||||
//-----------------------------------------------------------------------
|
||||
// Logging Commands
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Writes debug message to user log
|
||||
* @param message debug message
|
||||
*/
|
||||
function debug(message) {
|
||||
command_1.issueCommand('debug', {}, message);
|
||||
}
|
||||
exports.debug = debug;
|
||||
/**
|
||||
* Adds an error issue
|
||||
* @param message error issue message
|
||||
*/
|
||||
function error(message) {
|
||||
command_1.issue('error', message);
|
||||
}
|
||||
exports.error = error;
|
||||
/**
|
||||
* Adds an warning issue
|
||||
* @param message warning issue message
|
||||
*/
|
||||
function warning(message) {
|
||||
command_1.issue('warning', message);
|
||||
}
|
||||
exports.warning = warning;
|
||||
/**
|
||||
* Writes info to log with console.log.
|
||||
* @param message info message
|
||||
*/
|
||||
function info(message) {
|
||||
process.stdout.write(message + os.EOL);
|
||||
}
|
||||
exports.info = info;
|
||||
/**
|
||||
* Begin an output group.
|
||||
*
|
||||
* Output until the next `groupEnd` will be foldable in this group
|
||||
*
|
||||
* @param name The name of the output group
|
||||
*/
|
||||
function startGroup(name) {
|
||||
command_1.issue('group', name);
|
||||
}
|
||||
exports.startGroup = startGroup;
|
||||
/**
|
||||
* End an output group.
|
||||
*/
|
||||
function endGroup() {
|
||||
command_1.issue('endgroup');
|
||||
}
|
||||
exports.endGroup = endGroup;
|
||||
/**
|
||||
* Wrap an asynchronous function call in a group.
|
||||
*
|
||||
* Returns the same type as the function itself.
|
||||
*
|
||||
* @param name The name of the group
|
||||
* @param fn The function to wrap in the group
|
||||
*/
|
||||
function group(name, fn) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
startGroup(name);
|
||||
let result;
|
||||
try {
|
||||
result = yield fn();
|
||||
}
|
||||
finally {
|
||||
endGroup();
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
exports.group = group;
|
||||
//# sourceMappingURL=core.js.map
|
||||
1
node_modules/@actions/core/lib/core.js.map
generated
vendored
Normal file
1
node_modules/@actions/core/lib/core.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAA6C;AAE7C,yBAAwB;AACxB,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAEzB,6CAA6C;IAC7C,qDAAqD;IACrD,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;AACrC,CAAC;AAPD,oCAOC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAsB;IAC3D,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IACrE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AARD,4BAQC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED,yEAAyE;AACzE,UAAU;AACV,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAA;IACnC,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC;AAHD,8BAGC;AAED,yEAAyE;AACzE,mBAAmB;AACnB,yEAAyE;AAEzE;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,sBAAY,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC;AAED;;;GAGG;AACH,SAAgB,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC;AAFD,oBAEC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,eAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACtB,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,QAAQ;IACtB,eAAK,CAAC,UAAU,CAAC,CAAA;AACnB,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAI,IAAY,EAAE,EAAoB;;QAC/D,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC"}
|
||||
64
node_modules/@actions/core/package.json
generated
vendored
Normal file
64
node_modules/@actions/core/package.json
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"_from": "@actions/core@1.1.1",
|
||||
"_id": "@actions/core@1.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-O5G6EmlzTVsng7VSpNtszIoQq6kOgMGNTFB/hmwKNNA4V71JyxImCIrL27vVHCt2Cb3ImkaCr6o27C2MV9Ylwg==",
|
||||
"_location": "/@actions/core",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@actions/core@1.1.1",
|
||||
"name": "@actions/core",
|
||||
"escapedName": "@actions%2fcore",
|
||||
"scope": "@actions",
|
||||
"rawSpec": "1.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.1.tgz",
|
||||
"_shasum": "e08f3dbfe04721bb3d040f8fca2d6d7e1817b2e1",
|
||||
"_spec": "@actions/core@1.1.1",
|
||||
"_where": "/Users/bryan/Projects/javascript-action",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Actions core lib",
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.0.2"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "lib",
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
|
||||
"keywords": [
|
||||
"github",
|
||||
"actions",
|
||||
"core"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/core.js",
|
||||
"name": "@actions/core",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/actions/toolkit.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
"version": "1.1.1"
|
||||
}
|
||||
16503
package-lock.json
generated
16503
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
66
package.json
66
package.json
@@ -1,62 +1,32 @@
|
||||
{
|
||||
"name": "javascript-action",
|
||||
"description": "GitHub Actions JavaScript Template",
|
||||
"version": "0.0.0",
|
||||
"author": "",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"homepage": "https://github.com/actions/javascript-action#readme",
|
||||
"version": "1.0.0",
|
||||
"description": "JavaScript Action Template",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint index.js",
|
||||
"test": "eslint index.js && jest"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/actions/javascript-action.git"
|
||||
},
|
||||
"keywords": [
|
||||
"GitHub",
|
||||
"Actions",
|
||||
"JavaScript"
|
||||
],
|
||||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/javascript-action/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"actions"
|
||||
],
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"scripts": {
|
||||
"bundle": "npm run format:write && npm run package",
|
||||
"ci-test": "NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 npx jest",
|
||||
"coverage": "npx make-coverage-badge --output-path ./badges/coverage.svg",
|
||||
"format:write": "npx prettier --write .",
|
||||
"format:check": "npx prettier --check .",
|
||||
"lint": "npx eslint .",
|
||||
"local-action": "npx @github/local-action . src/main.js .env",
|
||||
"package": "npx rollup --config rollup.config.js",
|
||||
"package:watch": "npm run package -- --watch",
|
||||
"test": "NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 npx jest",
|
||||
"all": "npm run format:write && npm run lint && npm run test && npm run coverage && npm run package"
|
||||
},
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/actions/javascript-action#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.11.1"
|
||||
"@actions/core": "^1.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.4.0",
|
||||
"@github/local-action": "^6.0.2",
|
||||
"@jest/globals": "^30.2.0",
|
||||
"@rollup/plugin-commonjs": "^28.0.9",
|
||||
"@rollup/plugin-node-resolve": "^16.0.3",
|
||||
"eslint": "^9.38.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-jest": "^29.0.1",
|
||||
"eslint-plugin-prettier": "^5.5.4",
|
||||
"jest": "^30.2.0",
|
||||
"make-coverage-badge": "^1.2.0",
|
||||
"prettier": "^3.6.2",
|
||||
"prettier-eslint": "^16.4.2",
|
||||
"rollup": "^4.52.5"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@rollup/rollup-linux-x64-gnu": "*"
|
||||
"eslint": "^6.3.0",
|
||||
"jest": "^24.9.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// See: https://rollupjs.org/introduction/
|
||||
|
||||
import commonjs from '@rollup/plugin-commonjs'
|
||||
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
||||
|
||||
const config = {
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
esModule: true,
|
||||
file: 'dist/index.js',
|
||||
format: 'es',
|
||||
sourcemap: true
|
||||
},
|
||||
plugins: [commonjs(), nodeResolve({ preferBuiltins: true })]
|
||||
}
|
||||
|
||||
export default config
|
||||
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* The entrypoint for the action. This file simply imports and runs the action's
|
||||
* main logic.
|
||||
*/
|
||||
import { run } from './main.js'
|
||||
|
||||
/* istanbul ignore next */
|
||||
run()
|
||||
27
src/main.js
27
src/main.js
@@ -1,27 +0,0 @@
|
||||
import * as core from '@actions/core'
|
||||
import { wait } from './wait.js'
|
||||
|
||||
/**
|
||||
* The main function for the action.
|
||||
*
|
||||
* @returns {Promise<void>} Resolves when the action is complete.
|
||||
*/
|
||||
export async function run() {
|
||||
try {
|
||||
const ms = core.getInput('milliseconds')
|
||||
|
||||
// Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true
|
||||
core.debug(`Waiting ${ms} milliseconds ...`)
|
||||
|
||||
// Log the current timestamp, wait, then log the new timestamp
|
||||
core.debug(new Date().toTimeString())
|
||||
await wait(parseInt(ms, 10))
|
||||
core.debug(new Date().toTimeString())
|
||||
|
||||
// Set outputs for other workflow steps to use
|
||||
core.setOutput('time', new Date().toTimeString())
|
||||
} catch (error) {
|
||||
// Fail the workflow run if an error occurs
|
||||
if (error instanceof Error) core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
13
src/wait.js
13
src/wait.js
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* Waits for a number of milliseconds.
|
||||
*
|
||||
* @param {number} milliseconds The number of milliseconds to wait.
|
||||
* @returns {Promise<string>} Resolves with 'done!' after the wait is over.
|
||||
*/
|
||||
export async function wait(milliseconds) {
|
||||
return new Promise((resolve) => {
|
||||
if (isNaN(milliseconds)) throw new Error('milliseconds is not a number')
|
||||
|
||||
setTimeout(() => resolve('done!'), milliseconds)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user