An open API service indexing awesome lists of open source software.

https://github.com/gbudge/gha-ts-dev-container

Dev Container for developing GitHub Actions using Node.js and TypeScript.
https://github.com/gbudge/gha-ts-dev-container

actions devcontainer gha github-actions typescript

Last synced: about 2 months ago
JSON representation

Dev Container for developing GitHub Actions using Node.js and TypeScript.

Awesome Lists containing this project

README

          

# GitHub Actions Dev Container

This repository provides a reusable Dev Container for developing GitHub Actions using Node.js and TypeScript.

## Features

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.

## Quick Start

1. Clone this repository:
```bash
git clone my-github-action
cd my-github-action
```

2. Open the folder in VS Code and start the Dev Container:

![30176D3F-FD6B-4488-B513-08E2F20AD244](https://github.com/user-attachments/assets/3546cba9-61b6-4534-9313-37a8a3c877a8)

3. Run the setup script to initialize a new project:
```bash
.devcontainer/setup.sh
```

4. Update the `package.json` file (e.g. the `name`, `version`, `description`, etc.)

5. Start developing your GitHub Action in the `src/` directory!

6. Build and test with:
```bash
npm run build
npm run test
```

7. Happy coding.

## Project Structure

Below is the structure of a project initialized with this Dev Container:

```bash
.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.
```

## Running Tests

This repository includes a sample test for the GitHub Action logic. To run the tests:

1. Ensure you have run the setup script to initialize the test environment:
```bash
.devcontainer/setup.sh
```

2. Run the tests:
```bash
npm test
```

3. To view the test coverage report:
```bash
npm test -- --coverage
```

## Adding Your Own Action

1. Edit the `action.yml` file in the root of your project to define the action inputs and outputs.

2. Implement your action logic in the `src/main.ts` file.

3. Write corresponding tests in the `tests/` directory to ensure your action behaves as expected.

## License

This repository is licensed under the MIT License. See the `LICENSE` file for details.