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 * * *
|
- cron: 0 20,23,2,5 * * *
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
|
||||||
NODE_VERSION: 18
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
# Only cancel jobs for PR updates
|
# Only cancel jobs for PR updates
|
||||||
group: js-ci-${{ github.head_ref || github.run_id }}
|
group: js-ci-${{ github.head_ref || github.run_id }}
|
||||||
|
@ -21,6 +18,7 @@ concurrency:
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
|
working-directory: js
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
conditional:
|
conditional:
|
||||||
|
@ -35,41 +33,27 @@ jobs:
|
||||||
- id: conditional
|
- id: conditional
|
||||||
uses: ./.github/actions/conditional
|
uses: ./.github/actions/conditional
|
||||||
|
|
||||||
npm-run:
|
admin-client:
|
||||||
|
name: Admin Client
|
||||||
needs: conditional
|
needs: conditional
|
||||||
if: needs.conditional.outputs.js-ci == 'true'
|
if: needs.conditional.outputs.js-ci == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
env:
|
||||||
matrix:
|
WORKSPACE: "@keycloak/keycloak-admin-client"
|
||||||
include:
|
|
||||||
# Keycloak Admin Client
|
|
||||||
- workspace: "@keycloak/keycloak-admin-client"
|
|
||||||
command: lint
|
|
||||||
- workspace: "@keycloak/keycloak-admin-client"
|
|
||||||
command: build
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up Node.js
|
- uses: ./.github/actions/npm-setup
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
|
||||||
check-latest: true
|
|
||||||
cache: npm
|
|
||||||
cache-dependency-path: js/package-lock.json
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
working-directory: js
|
working-directory: js
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Run ${{ matrix.command }} task
|
- run: npm run lint --workspace=${{ env.WORKSPACE }}
|
||||||
working-directory: js
|
- run: npm run build --workspace=${{ env.WORKSPACE }}
|
||||||
run: npm run ${{ matrix.command }} --workspace=${{ matrix.workspace }}
|
|
||||||
|
|
||||||
check-set-status:
|
check-set-status:
|
||||||
name: Set check conclusion
|
name: Set check conclusion
|
||||||
needs:
|
needs:
|
||||||
- npm-run
|
- admin-client
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
conclusion: ${{ steps.check.outputs.conclusion }}
|
conclusion: ${{ steps.check.outputs.conclusion }}
|
||||||
|
|
Loading…
Reference in a new issue