Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/test-init-npm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Init-npm repository

on:
pull_request:
push:
branches:
- master
paths:
- "actions/init-npm/**"

jobs:
test-init-npm:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Test init-npm action
uses: ./actions/init-npm
with:
node-version: '20.x'
path: ./test
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This repository contains GitHub Actions used across the MapColonies organization
│ ├── build-docker/
│ ├── build-and-push-helm/
│ ├── helm-lint/
│ ├── init-npm/
│ ├── eslint/
│ ├── openapi-lint/
│ ├── push-docker/
Expand Down Expand Up @@ -51,6 +52,7 @@ Each action has a dedicated folder with:
| `helm-lint` | Lints and tests Helm charts |
| `eslint` | Runs ESLint to check JavaScript/TypeScript code |
| `openapi-lint` | Validates OpenAPI specs using Redocly CLI |
| `init-npm` | Initializes the repo with npm |
| `update-artifacts-file` | Updates `artifacts.json` metadata |

---
Expand Down
21 changes: 21 additions & 0 deletions actions/init-npm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Initialize NPM Action

This GitHub Action sets up Node.js, installs dependencies using npm, and builds the project.

## 🛠 Inputs

| Name | Description | Default | Required |
|----------------|---------------------------------------|---------|----------|
| `node_version` | Node.js version to set up ([supported versions](https://github.com/actions/setup-node#supported-version-syntax)) | `20.x` | false |
| `path` | Path to the directory containing your Node.js project | `.` | false |

## 🚀 Usage

<!-- x-release-please-start-version -->
```yaml
- name: Initialize NPM Project
uses: MapColonies/shared-workflows/actions/init-npm@init-npm-v0.0.0
with:
node-version: '20.x'
```
<!-- x-release-please-end-version -->
30 changes: 30 additions & 0 deletions actions/init-npm/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: init-npm
description: 'Initialize the repo with npm and install all the dependencies'
inputs:
node-version:
description: 'Node.js version'
required: true
default: '20.x'
path:
description: "Path to the Node.js directory"
default: "."
required: false
runs:
using: composite
steps:
- name: Set up Node.js
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
with:
node-version: ${{ inputs.node-version }}
cache: 'npm'
cache-dependency-path: ${{ inputs.path }}/package-lock.json

- name: Install TS Project dependencies
shell: bash
run: npm ci
working-directory: ${{ inputs.path }}

- name: build
shell: bash
run: npm run build
working-directory: ${{ inputs.path }}
5 changes: 5 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@
"release-type": "simple",
"package-name": "update-artifacts-file",
"extra-files": ["README.md"]
},
"actions/init-npm": {
"release-type": "simple",
"package-name": "init-npm",
"extra-files": ["README.md"]
}
}
}
Loading