diff --git a/.github/workflows/test-init-npm.yaml b/.github/workflows/test-init-npm.yaml new file mode 100644 index 0000000..1bb9d0c --- /dev/null +++ b/.github/workflows/test-init-npm.yaml @@ -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 diff --git a/README.md b/README.md index 1ff6a22..26dc4c0 100644 --- a/README.md +++ b/README.md @@ -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/ @@ -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 | --- diff --git a/actions/init-npm/README.md b/actions/init-npm/README.md new file mode 100644 index 0000000..d04ab97 --- /dev/null +++ b/actions/init-npm/README.md @@ -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 + + +```yaml +- name: Initialize NPM Project + uses: MapColonies/shared-workflows/actions/init-npm@init-npm-v0.0.0 + with: + node-version: '20.x' +``` + diff --git a/actions/init-npm/action.yaml b/actions/init-npm/action.yaml new file mode 100644 index 0000000..309514e --- /dev/null +++ b/actions/init-npm/action.yaml @@ -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 }} diff --git a/release-please-config.json b/release-please-config.json index 53333f1..d176a8d 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -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"] } } }