Skip to content

Commit 93a31e2

Browse files
authored
ci: Fix update workflow to use latest yarn.lock changes (#3379)
Currently we cache the `node_modules` folder and restore it from cache in the steps after. This means that any changes to the `yarn.lock` file made in the deduplication step are not used for generating LavaMoat policies or building the examples, sometimes resulting in errors. To fix it, I've added a check which checks if the `yarn.lock` was updated. The other steps will use a high risk environment which skips loading the `node_modules` cache if that's the case.
1 parent 75acad8 commit 93a31e2

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

.github/workflows/update-pull-request.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ jobs:
9292
name: Deduplicate yarn.lock
9393
runs-on: ubuntu-latest
9494
needs: prepare
95+
outputs:
96+
YARN_LOCK_CHANGED: ${{ steps.check-yarn-lock.outputs.YARN_LOCK_CHANGED }}
9597
steps:
9698
- name: Checkout repository
9799
uses: actions/checkout@v4
@@ -106,6 +108,10 @@ jobs:
106108
is-high-risk-environment: false
107109
- name: Deduplicate yarn.lock
108110
run: yarn dedupe
111+
- name: Check if yarn.lock changed
112+
id: check-yarn-lock
113+
run: |
114+
git diff --exit-code yarn.lock || echo "YARN_LOCK_CHANGED=true" >> "$GITHUB_OUTPUT"
109115
- name: Save yarn.lock
110116
uses: actions/upload-artifact@v4
111117
with:
@@ -133,7 +139,8 @@ jobs:
133139
- name: Checkout and setup environment
134140
uses: MetaMask/action-checkout-and-setup@v1
135141
with:
136-
is-high-risk-environment: false
142+
# If the Yarn lock changed we need to reinstall the dependencies.
143+
is-high-risk-environment: ${{ needs.dedupe-yarn-lock.outputs.YARN_LOCK_CHANGED == 'true' }}
137144
- name: Regenerate LavaMoat policies
138145
run: yarn build:lavamoat:policy
139146
- name: Save LavaMoat policies
@@ -165,7 +172,8 @@ jobs:
165172
- name: Checkout and setup environment
166173
uses: MetaMask/action-checkout-and-setup@v1
167174
with:
168-
is-high-risk-environment: false
175+
# If the Yarn lock changed we need to reinstall the dependencies.
176+
is-high-risk-environment: ${{ needs.dedupe-yarn-lock.outputs.YARN_LOCK_CHANGED == 'true' }}
169177
- name: Build dependencies
170178
run: |
171179
yarn build:ci

0 commit comments

Comments
 (0)