Skip to content

Commit

Permalink
ci: compoiste steps to remove duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
h-takeyeah committed Mar 8, 2024
1 parent 414ab59 commit 1106339
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
31 changes: 31 additions & 0 deletions .github/actions/prepare-nodemodules/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Prepare node_modules

description: Install Dependencies using Bun. If cache hit, do nothing.

inputs:
root:
description: |-
An absolute path to the directory where contains package.json.
Required
required: true

runs:
using: composite
steps:
- uses: actions/cache@v4
id: cache
working-directory: ${{ inputs.root }}
with:
path: |
~/.bun/install/cache
${{ inputs.root }}/.next/cache
key: ${{ runner.os }}-bun-cache-${{ hashFiles('bun.lockb') }}
restore-keys: ${{ runner.os }}-bun-cache-
- uses: oven-sh/setup-bun@v1
if: steps.cache.outputs.cache-hit != 'true'
with:
bun-version: latest
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{ inputs.root }}
run: bun install
16 changes: 2 additions & 14 deletions .github/workflows/nodejsci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
id: cache
- uses: ./.github/actions/prepare-nodemodules
with:
path: |
${{ github.workspace }}/typing-app/node_modules
${{ github.workspace }}/typing-app/.next/cache
key: ${{ runner.os }}-bun-cache-${{ hashFiles('typing-app/bun.lockb') }}
restore-keys: ${{ runner.os }}-bun-cache-
- uses: oven-sh/setup-bun@v1
if: steps.cache.outputs.cache-hit != 'true'
with:
bun-version: latest
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: bun install
root: ${{ github.workspace }}/typing-app
- name: Try to build
run: npm run build

Expand Down

0 comments on commit 1106339

Please sign in to comment.