From db12ea66697e822bfc5c74bfa58a5c2435ae724f Mon Sep 17 00:00:00 2001 From: Trezy Date: Wed, 31 Jul 2024 11:39:12 -0500 Subject: [PATCH] ci: update node setup --- .github/actions/setup/action.yml | 26 ++++++++++++------- .../workflows/handle-release-branch-push.yml | 16 ++++-------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 61701270..19583663 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,25 +1,33 @@ -name: "Install Project" +name: "Setup the project" description: "Installs node, npm, and dependencies" runs: using: "composite" steps: - - name: Use Node.js + - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: lts/* registry-url: "https://registry.npmjs.org" - - name: Cache Dependencies - id: node-modules-cache + - name: Get npm cache directory + id: npm-cache-dir + shell: bash + run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} + + - name: Cache dependencies uses: actions/cache@v4 + id: npm-cache with: - path: node_modules - key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }} + path: ${{ steps.npm-cache-dir.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | - ${{ runner.os }}-node-modules- + ${{ runner.os }}-node- - - name: Install Dependencies + - name: Install dependencies if: steps.node-modules-cache.outputs.cache-hit != 'true' shell: bash - run: npm ci + run: npm ci --ignore-scripts --no-audit --no-fund + + - name: Rebuild binaries + run: npm rebuild diff --git a/.github/workflows/handle-release-branch-push.yml b/.github/workflows/handle-release-branch-push.yml index 220da323..5767c949 100644 --- a/.github/workflows/handle-release-branch-push.yml +++ b/.github/workflows/handle-release-branch-push.yml @@ -5,7 +5,7 @@ on: jobs: verify: - name: CI + name: Verify runs-on: ubuntu-latest strategy: matrix: @@ -22,20 +22,14 @@ jobs: with: fetch-depth: 0 - - name: Setup Node - uses: actions/setup-node@v4 - - - name: Install dependencies - run: npm ci --ignore-scripts --no-audit --no-fund - - - name: Rebuild binaries - run: npm rebuild + - name: Setup + uses: ./.github/actions/setup - name: ${{ matrix.script.name }} run: npm run ${{ matrix.script.command }} publish: - name: Publish release + name: Publish needs: - verify if: contains(fromJson('["refs/heads/alpha", "refs/heads/beta", "refs/heads/main"]'), github.ref) @@ -46,7 +40,7 @@ jobs: with: fetch-depth: 0 - - name: Publish Release + - name: Publish release uses: ./.github/actions/publish-release with: branchName: ${{ github.head_ref || github.ref_name }}