Move NPM and Node.js setup into re-usable workflow (#16994)
This commit is contained in:
parent
dc8b759c3d
commit
dc2c73bb30
2 changed files with 39 additions and 26 deletions
29
.github/actions/npm-setup/action.yml
vendored
Normal file
29
.github/actions/npm-setup/action.yml
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
name: Setup NPM
|
||||
description: Sets up Node.js and runs NPM so dependencies are installed.
|
||||
|
||||
inputs:
|
||||
node-version:
|
||||
description: Node.js version
|
||||
required: false
|
||||
default: "18"
|
||||
|
||||
working-directory:
|
||||
description: The working directory where the `package-lock.json` is located.
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ inputs.node-version }}
|
||||
check-latest: true
|
||||
cache: npm
|
||||
cache-dependency-path: ${{ inputs.working-directory }}/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: bash
|
||||
run: npm ci
|
34
.github/workflows/js-ci.yml
vendored
34
.github/workflows/js-ci.yml
vendored
|
@ -10,9 +10,6 @@ on:
|
|||
- cron: 0 20,23,2,5 * * *
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
NODE_VERSION: 18
|
||||
|
||||
concurrency:
|
||||
# Only cancel jobs for PR updates
|
||||
group: js-ci-${{ github.head_ref || github.run_id }}
|
||||
|
@ -21,6 +18,7 @@ concurrency:
|
|||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: js
|
||||
|
||||
jobs:
|
||||
conditional:
|
||||
|
@ -35,41 +33,27 @@ jobs:
|
|||
- id: conditional
|
||||
uses: ./.github/actions/conditional
|
||||
|
||||
npm-run:
|
||||
admin-client:
|
||||
name: Admin Client
|
||||
needs: conditional
|
||||
if: needs.conditional.outputs.js-ci == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# Keycloak Admin Client
|
||||
- workspace: "@keycloak/keycloak-admin-client"
|
||||
command: lint
|
||||
- workspace: "@keycloak/keycloak-admin-client"
|
||||
command: build
|
||||
env:
|
||||
WORKSPACE: "@keycloak/keycloak-admin-client"
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3
|
||||
- uses: ./.github/actions/npm-setup
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
check-latest: true
|
||||
cache: npm
|
||||
cache-dependency-path: js/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: js
|
||||
run: npm ci
|
||||
|
||||
- name: Run ${{ matrix.command }} task
|
||||
working-directory: js
|
||||
run: npm run ${{ matrix.command }} --workspace=${{ matrix.workspace }}
|
||||
- run: npm run lint --workspace=${{ env.WORKSPACE }}
|
||||
- run: npm run build --workspace=${{ env.WORKSPACE }}
|
||||
|
||||
check-set-status:
|
||||
name: Set check conclusion
|
||||
needs:
|
||||
- npm-run
|
||||
- admin-client
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
conclusion: ${{ steps.check.outputs.conclusion }}
|
||||
|
|
Loading…
Reference in a new issue