This repository provides a reusable Dev Container for developing GitHub Actions using Node.js and TypeScript.
Pre-installed Tools:
- Node.js and TypeScript
- GitHub CLI (gh)
- Common libraries:
@actions/core
,@actions/github
- Testing tools: Jest and ts-jest
- Linting and formatting: ESLint and Prettier
- Example
action.yml
, TypeScript configuration, example code, and tests.
-
Clone this repository:
git clone <repository-url> my-github-action cd my-github-action
-
Open the folder in VS Code and start the Dev Container:
-
Run the setup script to initialize a new project:
.devcontainer/setup.sh
-
Update the
package.json
file (e.g. thename
,version
,description
, etc.) -
Start developing your GitHub Action in the
src/
directory! -
Build and test with:
npm run build npm run test
-
Happy coding.
Below is the structure of a project initialized with this Dev Container:
.github/ # GitHub-specific files.
.devcontainer/ # Dev Container configuration and setup scripts.
README.md # Documentation for using this repository.
src/
action.yml # Sample GitHub Action metadata.
tsconfig.json # TypeScript configuration.
src/ # Sample TypeScript source code.
tests/ # Sample Jest tests.
This repository includes a sample test for the GitHub Action logic. To run the tests:
-
Ensure you have run the setup script to initialize the test environment:
.devcontainer/setup.sh
-
Run the tests:
npm test
-
To view the test coverage report:
npm test -- --coverage
-
Edit the
action.yml
file in the root of your project to define the action inputs and outputs. -
Implement your action logic in the
src/main.ts
file. -
Write corresponding tests in the
tests/
directory to ensure your action behaves as expected.
This repository is licensed under the MIT License. See the LICENSE
file for details.