From a903cf2d6682e8f10611d7038ef6a67c58902ed4 Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Thu, 12 Oct 2023 13:11:41 -0400 Subject: [PATCH] Add install deps action to reuse between workflows --- .../actions/install-dependencies/action.yml | 11 ++++++++ .github/workflows/check-dist.yml | 8 +----- .github/workflows/ci.yml | 6 +--- .github/workflows/integration.yml | 28 +++---------------- .github/workflows/licensed.yml | 6 +--- 5 files changed, 18 insertions(+), 41 deletions(-) create mode 100644 .github/actions/install-dependencies/action.yml diff --git a/.github/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml new file mode 100644 index 0000000..81e1457 --- /dev/null +++ b/.github/actions/install-dependencies/action.yml @@ -0,0 +1,11 @@ +name: 'Install dependencies' +description: 'Set up node and install dependencies' +runs: + using: 'composite' + steps: + - uses: actions/setup-node@v3 + with: + node-version: '20.x' + cache: npm + + - run: npm ci diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 37fc418..817ad8b 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -20,13 +20,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: '20.x' - cache: npm - - - name: Install dependencies - run: npm ci + - uses: ./.github/actions/install-dependencies - name: Rebuild the dist/ directory run: npm run build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3868250..dd2216d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,10 +11,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: '20.x' - cache: npm - - run: npm ci + - uses: ./.github/actions/install-dependencies - run: npm run style:check - run: npm test diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 7c86358..433dfb5 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -50,12 +50,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/cache@v3 - with: - path: ~/.npm - key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}} - restore-keys: ${{runner.os}}-npm- - - run: npm ci + - uses: ./.github/actions/install-dependencies - id: npm-require uses: ./ with: @@ -75,12 +70,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/cache@v3 - with: - path: ~/.npm - key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}} - restore-keys: ${{runner.os}}-npm- - - run: npm ci + - uses: ./.github/actions/install-dependencies - id: previews-default name: Default previews not set uses: ./ @@ -133,12 +123,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/cache@v3 - with: - path: ~/.npm - key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}} - restore-keys: ${{runner.os}}-npm- - - run: npm ci + - uses: ./.github/actions/install-dependencies - id: user-agent-default name: Default user-agent not set uses: ./ @@ -195,12 +180,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/cache@v3 - with: - path: ~/.npm - key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}} - restore-keys: ${{runner.os}}-npm- - - run: npm ci + - uses: ./.github/actions/install-dependencies - id: debug-default name: Default debug not set uses: ./ diff --git a/.github/workflows/licensed.yml b/.github/workflows/licensed.yml index 36a97ef..7afc7a3 100644 --- a/.github/workflows/licensed.yml +++ b/.github/workflows/licensed.yml @@ -20,9 +20,5 @@ jobs: - uses: jonabc/setup-licensed@82c5f4d19e8968efa74a25b132922382c2671fe2 with: version: '3.x' - - uses: actions/setup-node@v3 - with: - node-version: '20.x' - cache: npm - - run: npm ci + - uses: ./.github/actions/install-dependencies - run: licensed status