Skip to content

Commit

Permalink
Simplify Github Actions configuration by extracting common steps into…
Browse files Browse the repository at this point in the history
  • Loading branch information
e1himself committed May 9, 2023
1 parent 2b0f956 commit a74fd2d
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 261 deletions.
90 changes: 35 additions & 55 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,39 @@
name: Build

on: [push]
on: push

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
react-version: [16.14.0, 17, 18]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8.4.0
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Set React ${{ matrix.react-version }}
uses: jossef/action-set-json-field@v2.1
with:
file: package.json
parse_json: true
field: pnpm.overrides
value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}'
env:
REACT_TYPES_VERSION: ${{ matrix.react-version }}
REACT_VERSION: ${{ matrix.react-version }}
REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }}
REACT_DOM_VERSION: ${{ matrix.react-version }}

- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- run: pnpm build
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 16.x ]
react-version: [ 16.14.0, 17, 18 ]

steps:
- uses: actions/checkout@v2

- name: Setup Environment
uses: prezly/setup-github-actions@v1
with:
node: ${{ matrix.node-version }}
pnpm: "8.4.0"

- name: Set React ${{ matrix.react-version }}
uses: jossef/action-set-json-field@v2.1
with:
file: package.json
parse_json: true
field: pnpm.overrides
value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}'
env:
REACT_TYPES_VERSION: ${{ matrix.react-version }}
REACT_VERSION: ${{ matrix.react-version }}
REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }}
REACT_DOM_VERSION: ${{ matrix.react-version }}

- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- run: pnpm build
86 changes: 33 additions & 53 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,37 @@
name: Dependencies Alignment

on: [push]
on: push

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
react-version: [16.14.0, 17, 18]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8.4.0
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Set React ${{ matrix.react-version }}
uses: jossef/action-set-json-field@v2.1
with:
file: package.json
parse_json: true
field: pnpm.overrides
value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}'
env:
REACT_TYPES_VERSION: ${{ matrix.react-version }}
REACT_VERSION: ${{ matrix.react-version }}
REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }}
REACT_DOM_VERSION: ${{ matrix.react-version }}

- name: Install dependencies
run: pnpm install --no-frozen-lockfile --strict-peer-dependencies --ignore-pnpmfile --prod
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 16.x ]
react-version: [ 16.14.0, 17, 18 ]

steps:
- uses: actions/checkout@v2

- name: Setup Environment
uses: prezly/setup-github-actions@v1
with:
node: ${{ matrix.node-version }}
pnpm: "8.4.0"

- name: Set React ${{ matrix.react-version }}
uses: jossef/action-set-json-field@v2.1
with:
file: package.json
parse_json: true
field: pnpm.overrides
value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}'
env:
REACT_TYPES_VERSION: ${{ matrix.react-version }}
REACT_VERSION: ${{ matrix.react-version }}
REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }}
REACT_DOM_VERSION: ${{ matrix.react-version }}

- name: Install dependencies
run: pnpm install --no-frozen-lockfile --strict-peer-dependencies --ignore-pnpmfile --prod
52 changes: 16 additions & 36 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,25 @@
name: Prettier

on: [push]
on: push

jobs:
build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
strategy:
matrix:
node-version: [ 16.x ]

steps:
- uses: actions/checkout@v2
steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Setup Environment
uses: prezly/setup-github-actions@v1
with:
node: ${{ matrix.node-version }}
pnpm: "8.4.0"

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8.4.0
run_install: false
- name: Install dependencies
run: pnpm install

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- run: pnpm prettier
- run: pnpm prettier
100 changes: 40 additions & 60 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,44 @@
name: Build Storybook

on: [push]
on: push

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
react-version: [16.14.0, 17, 18]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8.4.0
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Set React ${{ matrix.react-version }}
uses: jossef/action-set-json-field@v2.1
with:
file: package.json
parse_json: true
field: pnpm.overrides
value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}'
env:
REACT_TYPES_VERSION: ${{ matrix.react-version }}
REACT_VERSION: ${{ matrix.react-version }}
REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }}
REACT_DOM_VERSION: ${{ matrix.react-version }}

- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Build Project
run: pnpm build

- name: Build Storybook
run: pnpm storybook:build
working-directory: packages/slate-editor
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 16.x ]
react-version: [ 16.14.0, 17, 18 ]

steps:
- uses: actions/checkout@v2

- name: Setup Environment
uses: prezly/setup-github-actions@v1
with:
node: ${{ matrix.node-version }}
pnpm: "8.4.0"

- name: Set React ${{ matrix.react-version }}
uses: jossef/action-set-json-field@v2.1
with:
file: package.json
parse_json: true
field: pnpm.overrides
value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}'
env:
REACT_TYPES_VERSION: ${{ matrix.react-version }}
REACT_VERSION: ${{ matrix.react-version }}
REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }}
REACT_DOM_VERSION: ${{ matrix.react-version }}

- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Build Project
run: pnpm build

- name: Build Storybook
run: pnpm storybook:build
working-directory: packages/slate-editor
Loading

0 comments on commit a74fd2d

Please sign in to comment.