Skip to content

Commit

Permalink
chore: Rework deduplication github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
burtek committed Sep 5, 2024
1 parent 47bdd57 commit 9d162eb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
24 changes: 24 additions & 0 deletions .github/actions/deduplicate/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Deduplicate'

inputs:
strategy:
description: 'yarn-deduplicate strategy'
required: true

runs:
using: "composite"
steps:
- name: Run yarn-deduplicate (highest)
if: ${{ env.STRATEGY == 'highest' }}
run: |
yarn global add yarn-deduplicate
yarn-deduplicate --strategy highest
yarn-deduplicate --strategy fewer --packages @types/node # @types/node@* causes unneeded duplication in highest mode
yarn
- name: Run yarn-deduplicate (fewer)
if: ${{ env.STRATEGY == 'fewer' }}
run: |
yarn global add yarn-deduplicate
yarn-deduplicate --strategy fewer --exclude @types/unist # @types/unist gets downgraded in this mode
yarn
7 changes: 3 additions & 4 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ jobs:
- name: 'Prepare workflow'
uses: ./.github/actions/prepare
- name: 'Deduplicate dependencies'
run: |
yarn global add yarn-deduplicate
yarn-deduplicate
yarn
uses: ./.github/actions/deduplicate
with:
strategy: 'highest'
- name: 'Verify yarn.lock is intact'
run: git diff --exit-code yarn.lock
- name: 'Notify of duplicates'
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/deduplicate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,10 @@ jobs:
- name: 'Prepare workflow'
uses: ./.github/actions/prepare

- name: Run yarn-deduplicate
env:
ARGS: ${{ contains(github.event.comment.body, 'fewer') && '--exclude @types/unist' || '' }}
run: |
yarn global add yarn-deduplicate
yarn-deduplicate --strategy $STRATEGY $ARGS
yarn
- name: 'Deduplicate dependencies'
uses: ./.github/actions/deduplicate
with:
strategy: ${{ env.STRATEGY }}

- name: Commit changes
run: |
Expand Down

0 comments on commit 9d162eb

Please sign in to comment.