Skip to content

Commit

Permalink
ci: create reusable setup action
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcdo29 committed Jan 31, 2022
1 parent d94ab05 commit 1cc65c8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 43 deletions.
24 changes: 24 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Set up action environment'
description: 'Install Node, pnpm, and install deps with caching'
runs:
using: 'composite'
steps:
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: 16.x

- name: Cache pnpm modules
uses: actions/cache@v2
if: ${{ !contains(github.event.pull_request.user.login, 'bot') }}
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- name: Install pnpm
uses: pnpm/action-setup@v2.0.1
with:
version: 6
run_install: true
27 changes: 6 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ jobs:
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
- uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Install pnpm
run: npm i -g pnpm
- name: Install deps
run: pnpm i
- name: Setup
uses: ./.github/actions/setup
- name: Lint
run: pnpm lint
- name: Build Projects
Expand All @@ -49,15 +44,10 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Debug ternary
run: echo ${{ startsWith(github.repository, 'jmcdo29') && 'In repo' || 'from fork' }}
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
- uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Install pnpm
run: npm i -g pnpm
- name: Setup
uses: ./.github/actions/setup
- name: Install deps
run: pnpm i
- name: Lint
Expand Down Expand Up @@ -109,12 +99,7 @@ jobs:
agent: [ 1, 2, 3 ]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Install pnpm
run: npm i -g pnpm
- name: Install deps
run: pnpm i
- name: Setup
uses: ./.github/actions/setup
- name: Start Nx Agent ${{ matrix.agent }}
run: pnpm nx-cloud start-agent
9 changes: 2 additions & 7 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,8 @@ jobs:
if: ${{ needs.changes.outputs.files == 'true' }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14.x'
- name: Install pnpm
run: npm i -g pnpm
- name: Dependencies Install
run: pnpm i
- name: Setup
uses: ./.github/actions/setup
- name: Build Docs
run: pnpm nx build docs
- uses: webfactory/ssh-agent@v0.5.4
Expand Down
19 changes: 4 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,8 @@ jobs:
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2

- name: Setup Node.js 14.x
uses: actions/setup-node@master
with:
node-version: 14.x

- name: Install pnpm
run: npm i -g pnpm

- name: Install Dependencies
run: pnpm i
- name: Setup
uses: ./.github/actions/setup

- name: Build Projects
run: pnpm build
Expand All @@ -58,11 +50,8 @@ jobs:
name: Nx Agent
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Install pnpm
run: npm i -g pnpm
- name: Setup
uses: ./.github/actions/setup

- name: Install Dependencies
run: pnpm i
Expand Down

0 comments on commit 1cc65c8

Please sign in to comment.