Skip to content

Commit 9c82477

Browse files
committed
chore: add demo-strapi-version-check GH action
1 parent f2e4a77 commit 9c82477

File tree

2 files changed

+100
-4
lines changed

2 files changed

+100
-4
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: 'Demo App Strapi Version Check'
2+
3+
on:
4+
schedule:
5+
- cron: '0 23 * * 3' # Run weekly on Wednesday at 23:00 UTC
6+
workflow_dispatch: # Allow manual trigger
7+
8+
permissions:
9+
contents: write # to create branch and PR
10+
pull-requests: write # to create PR
11+
12+
jobs:
13+
check-and-update:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- name: Install pnpm
23+
uses: pnpm/action-setup@v4
24+
with:
25+
version: 9.1.0
26+
27+
- name: Install Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 20
31+
32+
- name: Get current version from package.json
33+
id: current-version
34+
run: |
35+
CURRENT_VERSION=$(node -p "require('./demo/.strapi-app/package.json').dependencies['@strapi/strapi']")
36+
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
37+
echo "Current version: $CURRENT_VERSION"
38+
39+
- name: Get latest version from NPM
40+
id: latest-version
41+
run: |
42+
LATEST_VERSION=$(npm view @strapi/strapi version)
43+
echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT
44+
echo "Latest version: $LATEST_VERSION"
45+
46+
- name: Compare versions
47+
id: compare
48+
run: |
49+
if [ "${{ steps.current-version.outputs.current }}" = "${{ steps.latest-version.outputs.latest }}" ]; then
50+
echo "match=true" >> $GITHUB_OUTPUT
51+
echo "Versions match - no update needed"
52+
else
53+
echo "match=false" >> $GITHUB_OUTPUT
54+
echo "Versions don't match - update needed"
55+
fi
56+
57+
- name: Status check passed
58+
if: steps.compare.outputs.match == 'true'
59+
run: |
60+
echo "✅ Strapi version is up to date (${{ steps.current-version.outputs.current }})"
61+
62+
- name: Setup pnpm workspace
63+
if: steps.compare.outputs.match == 'false'
64+
working-directory: demo/.strapi-app
65+
run: |
66+
pnpm install --frozen-lockfile
67+
68+
- name: Upgrade Strapi packages
69+
if: steps.compare.outputs.match == 'false'
70+
working-directory: demo/.strapi-app
71+
run: |
72+
pnpm upgrade @strapi/plugin-users-permissions@${{ steps.latest-version.outputs.latest }} @strapi/plugin-cloud@${{ steps.latest-version.outputs.latest }} @strapi/strapi@${{ steps.latest-version.outputs.latest }}
73+
74+
- name: Create Pull Request
75+
if: steps.compare.outputs.match == 'false'
76+
uses: peter-evans/create-pull-request@v7
77+
with:
78+
token: ${{ secrets.GITHUB_TOKEN }}
79+
commit-message: 'chore: upgrade Strapi to ${{ steps.latest-version.outputs.latest }}'
80+
title: 'chore: upgrade Strapi to ${{ steps.latest-version.outputs.latest }}'
81+
body: |
82+
This PR automatically upgrades Strapi packages to the latest version.
83+
84+
- **Current version**: ${{ steps.current-version.outputs.current }}
85+
- **Latest version**: ${{ steps.latest-version.outputs.latest }}
86+
87+
Packages upgraded:
88+
- `@strapi/strapi`
89+
- `@strapi/plugin-users-permissions`
90+
- `@strapi/plugin-cloud`
91+
branch: chore/upgrade-strapi-${{ steps.latest-version.outputs.latest }}
92+
delete-branch: true
93+
labels: |
94+
dependencies
95+
automated
96+

demo/.strapi-app/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"strapi": "strapi"
1313
},
1414
"dependencies": {
15-
"@strapi/plugin-cloud": "latest",
16-
"@strapi/plugin-users-permissions": "latest",
17-
"@strapi/strapi": "latest",
15+
"@strapi/plugin-cloud": "5.31.0",
16+
"@strapi/plugin-users-permissions": "5.31.0",
17+
"@strapi/strapi": "5.31.0",
1818
"better-sqlite3": "11.3.0",
1919
"fs-extra": "^10.0.0",
2020
"mime-types": "^2.1.27",
@@ -36,4 +36,4 @@
3636
"strapi": {
3737
"uuid": "getstarted"
3838
}
39-
}
39+
}

0 commit comments

Comments
 (0)