Skip to content

Commit

Permalink
👷 chore(ci): Extract setup step to composite action (#924)
Browse files Browse the repository at this point in the history
  • Loading branch information
duckception authored Oct 9, 2023
1 parent 9ff2201 commit e58595c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 55 deletions.
7 changes: 7 additions & 0 deletions .github/actions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# .github/actions

Reusable actions for GitHub workflows.

## [⚙️ Setup](setup/action.yml)

Setups Node environment and installs dependencies.
18 changes: 18 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Setup Node & Install dependencies

runs:
using: composite
steps:
- uses: pnpm/action-setup@v2
with:
version: 8.7.6

- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
registry-url: https://registry.npmjs.org
cache: pnpm

- name: Install dependencies
shell: bash
run: pnpm install --frozen-lockfile
2 changes: 1 addition & 1 deletion .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# .github/workflows

CI Workflows
CI Workflows.

## [🦄 pr.yml](pr.yml)

Expand Down
14 changes: 2 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,8 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: 8.7.6

- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
registry-url: https://registry.npmjs.org
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Setup Node & Install dependencies
uses: ./.github/actions/setup

- name: Check linter
run: pnpm run lint:check
Expand Down
20 changes: 2 additions & 18 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,8 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: 8.7.6

# Fetches the config package version from the `pnpm-lock.yaml` file.
- name: Fetch config package version
id: config-package-version
env:
GITMOJI_CONFIG_PACKAGE: "commitlint-config-gitmoji"
run: |
echo "CONFIG_PACKAGE=$(grep -A 2 "$GITMOJI_CONFIG_PACKAGE" pnpm-lock.yaml | awk '/version:/ {print "'"$GITMOJI_CONFIG_PACKAGE"'@" $2}')" >> "$GITHUB_OUTPUT"
# Installs only the config package required for commitlint.
- name: Install config package
env:
CONFIG_PACKAGE: "${{ steps.config-package-version.outputs.CONFIG_PACKAGE }}"
run: |
pnpm add -w "$CONFIG_PACKAGE"
- name: Setup Node & Install dependencies
uses: ./.github/actions/setup

# The validation is done based on the `commitlint.config.js` file.
- name: Validate PR title
Expand Down
28 changes: 4 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,8 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: 8.7.6

- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
registry-url: https://registry.npmjs.org
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Setup Node & Install dependencies
uses: ./.github/actions/setup

- name: Build project
run: pnpm run build
Expand All @@ -38,18 +28,8 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: 8.7.6

- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
registry-url: https://registry.npmjs.org
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Setup Node & Install dependencies
uses: ./.github/actions/setup

# For now, we only need Chromium.
- name: Install browsers for Playwright
Expand Down

0 comments on commit e58595c

Please sign in to comment.