Skip to content

Commit 014f615

Browse files
committed
chore: Create pull request only if yarn version is outdated
1 parent 6f95c7e commit 014f615

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

.github/workflows/yarn_update.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ permissions:
77
on:
88
schedule:
99
- cron: '0 5 1 * *'
10+
push:
11+
branches:
12+
- main
13+
paths:
14+
- '.github/workflows/yarn_update.yml'
1015

1116
jobs:
1217
yarn-update-check:
@@ -19,26 +24,31 @@ jobs:
1924
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238
2025
with:
2126
node-version: 24
22-
cache: yarn
2327

2428
- name: Update yarn
25-
id: check-yarn-version
29+
id: update-yarn
2630
run: |
27-
echo "Old version: $(yarn --version)"
31+
OLD_VERSION=$(yarn --version)
2832
yarn set version stable
29-
echo "New version: $(yarn --version)"
30-
echo "YARN_VERSION=$(yarn --version)" >> "${GITHUB_OUTPUT}"
33+
NEW_VERSION=$(yarn --version)
34+
if [ "${OLD_VERSION}" == "${NEW_VERSION}" ]; then
35+
echo "yarn is already up to date."
36+
else
37+
echo "yarn updated to version ${NEW_VERSION}."
38+
echo "YARN_VERSION=${NEW_VERSION}" >> $GITHUB_OUTPUT
39+
fi
3140
3241
- name: Create Pull Request
42+
if: steps.update-yarn.outputs.YARN_VERSION != ''
3343
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0
3444
with:
3545
author: 'Florian Imdahl <git@ffflorian.de>'
3646
committer: 'Florian Imdahl <git@ffflorian.de>'
3747
base: main
3848
body: |
39-
This PR updates yarn to version **${{ steps.check-yarn-version.outputs.YARN_VERSION }}**.
49+
This PR updates yarn to version **${{ steps.update-yarn.outputs.YARN_VERSION }}**.
4050
41-
See the [release notes](https://github.com/yarnpkg/berry/releases/tag/%40yarnpkg%2Fcli%2F${{ steps.check-yarn-version.outputs.YARN_VERSION }}) for more details.
42-
branch: 'chore/deps/yarn-${{ steps.check-yarn-version.outputs.YARN_VERSION }}'
43-
commit-message: 'chore(deps): Update yarn to version ${{ steps.check-yarn-version.outputs.YARN_VERSION }}'
44-
title: 'chore(deps): Update yarn to version ${{ steps.check-yarn-version.outputs.YARN_VERSION }}'
51+
See the [release notes](https://github.com/yarnpkg/berry/releases/tag/%40yarnpkg%2Fcli%2F${{ steps.update-yarn.outputs.YARN_VERSION }}) for more details.
52+
branch: 'chore/deps/yarn-${{ steps.update-yarn.outputs.YARN_VERSION }}'
53+
commit-message: 'chore(deps): bump yarn to version ${{ steps.update-yarn.outputs.YARN_VERSION }}'
54+
title: 'chore(deps): Update yarn to version ${{ steps.update-yarn.outputs.YARN_VERSION }}'

0 commit comments

Comments
 (0)