From ca98bc99f739ae3cbe01a10c448b6d51ff4ba772 Mon Sep 17 00:00:00 2001 From: Olivier Penhoat Date: Sat, 21 Oct 2023 06:45:12 +0200 Subject: [PATCH] [BUILD] Add CI pipeline --- .github/actions/install-action/action.yaml | 30 ++++++++++++++++++++++ .github/workflows/build.yaml | 30 ++++++++++++++++++++++ README.md | 2 ++ 3 files changed, 62 insertions(+) create mode 100644 .github/actions/install-action/action.yaml create mode 100644 .github/workflows/build.yaml diff --git a/.github/actions/install-action/action.yaml b/.github/actions/install-action/action.yaml new file mode 100644 index 0000000..9d0bf05 --- /dev/null +++ b/.github/actions/install-action/action.yaml @@ -0,0 +1,30 @@ +name: install +description: Install specific version of Node and NPM + +inputs: + node-version: + description: NodeJS version + required: true + npm-version: + description: NPM version + required: true + +runs: + using: composite + steps: + - name: Install NodeJS version ${{ inputs.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.npm + key: npm-${{ hashFiles('package-lock.json') }} + restore-keys: npm- + - name: Install NPM + shell: bash + run: npm i -g npm@${NPM_VERSION} + - name: Install dependencies + shell: bash + run: npm ci --prefer-offline --include=dev --ignore-scripts diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..74b8c94 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,30 @@ +name: build + +env: + NODE_VERSION: '18.17.1' + NPM_VERSION: '9.8.1' + +on: + push: + branches: + - main + - develop + pull_request: + branches: + - main + - develop + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - name: Install project prerequisite + uses: ./.github/actions/install-action + with: + node-version: ${{env.NODE_VERSION}} + npm-version: ${{env.NPM_VERSION}} + - name: Validate project + run: npm run validate diff --git a/README.md b/README.md index faae2a0..03e5682 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![build](https://github.com/NijiDigital/space-invaders-ascii-nodejs/actions/workflows/build.yaml/badge.svg)](https://github.com/NijiDigital/space-invaders-ascii-nodejs/actions/workflows/build.yaml) + ## Space Invaders A space invaders game in ASCII art made with love, NodeJS and TypeScript.