File tree Expand file tree Collapse file tree 2 files changed +51
-18
lines changed Expand file tree Collapse file tree 2 files changed +51
-18
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -ex
4
+
5
+ if git diff --exit-code yarn.lock; then
6
+ echo " ✅ yarn.lock is already properly deduplicated"
7
+ else
8
+ echo " 📝 yarn.lock was modified by dedupe command"
9
+
10
+ PR_AUTHOR=" ${PR_AUTHOR:- } "
11
+ PR_USER_TYPE=" ${PR_USER_TYPE:- } "
12
+
13
+ if [[ " $PR_USER_TYPE " == " Bot" ]] && [[ " ${GITHUB_EVENT_NAME:- } " == " pull_request" ]]; then
14
+ echo " 🤖 Bot-created PR detected. Auto-committing yarn.lock changes..."
15
+
16
+ git config --local user.email " action@github.com"
17
+ git config --local user.name " GitHub Action"
18
+
19
+ git add yarn.lock
20
+ git commit -m " Auto-dedupe yarn.lock dependencies"
21
+
22
+ git push origin HEAD:${GITHUB_HEAD_REF}
23
+
24
+ echo " ✅ Successfully committed and pushed yarn.lock deduplication"
25
+ else
26
+ echo " ❌ The yarn.lock file needs deduplication!"
27
+ echo " "
28
+ echo " The yarn dedupe command has modified your yarn.lock file."
29
+ echo " This means there were duplicate dependencies that could be optimized."
30
+ echo " "
31
+ echo " To fix this issue:"
32
+ echo " 1. Run 'yarn dependencies:dedupe' locally"
33
+ echo " 2. Commit the updated yarn.lock file"
34
+ echo " 3. Push your changes"
35
+ echo " "
36
+ echo " This helps keep the dependency tree clean."
37
+ exit 1
38
+ fi
39
+ fi
Original file line number Diff line number Diff line change 99
99
100
100
yarn-dedupe :
101
101
runs-on : ubuntu-latest
102
+ permissions :
103
+ contents : write
104
+ pull-requests : read
102
105
steps :
103
106
- name : Checkout code
104
107
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
108
+ with :
109
+ token : ${{ secrets.GITHUB_TOKEN }}
110
+ fetch-depth : 0
105
111
106
112
- name : Setup Node.js
107
113
uses : ./.github/actions/node/active-lts
@@ -112,21 +118,9 @@ jobs:
112
118
- name : Run yarn dependencies:dedupe
113
119
run : yarn dependencies:dedupe
114
120
115
- - name : Check if yarn.lock was modified
116
- run : |
117
- if git diff --exit-code yarn.lock; then
118
- echo "✅ yarn.lock is already properly deduplicated"
119
- else
120
- echo "❌ The yarn.lock file needs deduplication!"
121
- echo ""
122
- echo "The yarn dedupe command has modified your yarn.lock file."
123
- echo "This means there were duplicate dependencies that could be optimized."
124
- echo ""
125
- echo "To fix this issue:"
126
- echo "1. Run 'yarn dependencies:dedupe' locally"
127
- echo "2. Commit the updated yarn.lock file"
128
- echo "3. Push your changes"
129
- echo ""
130
- echo "This helps keep the dependency tree clean."
131
- exit 1
132
- fi
121
+ - name : Run yarn dedupe check
122
+ run : ./.github/scripts/yarn-dedupe.sh
123
+ env :
124
+ PR_AUTHOR : ${{ github.event.pull_request.user.login }}
125
+ PR_USER_TYPE : ${{ github.event.pull_request.user.type }}
126
+ GITHUB_EVENT_NAME : ${{ github.event_name }}
You can’t perform that action at this time.
0 commit comments