Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/demo-strapi-version-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: 'Demo App Strapi Version Check'

on:
schedule:
- cron: '0 23 * * 3' # Run weekly on Wednesday at 23:00 UTC
workflow_dispatch: # Allow manual trigger

permissions:
contents: write # to create branch and PR
pull-requests: write # to create PR

jobs:
check-and-update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.1.0

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Get current version from package.json
id: current-version
run: |
CURRENT_VERSION=$(node -p "require('./demo/.strapi-app/package.json').dependencies['@strapi/strapi']")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With exact version being listed in package.json, it allows the action to use it as state and derive the comparison from it.
If we go back to latest, we'd have to either:

  • pnpm install then pnpm up ...@latest then, look into the node_modules/@strapi/strapi/package.json to observe a diff, then conditionally make the PR.
  • Rely on reading the lock file with a regex to match the @strapi/strapi version declaration, which I find clunky

@Convly @innerdvations can you detail the rationale/preference behind keeping latest instead of a pinned version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no strong opinion here, but I think I have to agree with Nico here regarding pinned versions in package.json
Having explicit versions in the diff makes it much easier to see what actually changed. It’s valuable for debugging and for understanding compatibility issues across both sides.

That said, I’d also suggest running the update job more frequently than once a week on Wednesday. We sometimes release on Thursdays, and we occasionally ship hotfixes as well. A more frequent schedule (e.g. daily ) would keep the example app synced much more reliably and reduce the lag between Strapi releases and the example’s updates.

echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"

- name: Get latest version from NPM
id: latest-version
run: |
LATEST_VERSION=$(npm view @strapi/strapi version)
echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT
echo "Latest version: $LATEST_VERSION"

- name: Compare versions
id: compare
run: |
if [ "${{ steps.current-version.outputs.current }}" = "${{ steps.latest-version.outputs.latest }}" ]; then
echo "match=true" >> $GITHUB_OUTPUT
echo "Versions match - no update needed"
else
echo "match=false" >> $GITHUB_OUTPUT
echo "Versions don't match - update needed"
fi

- name: Status check passed
if: steps.compare.outputs.match == 'true'
run: |
echo "✅ Strapi version is up to date (${{ steps.current-version.outputs.current }})"

- name: Setup pnpm workspace
if: steps.compare.outputs.match == 'false'
working-directory: demo/.strapi-app
run: |
pnpm install --frozen-lockfile

- name: Upgrade Strapi packages
if: steps.compare.outputs.match == 'false'
working-directory: demo/.strapi-app
run: |
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 }}

- name: Create Pull Request
if: steps.compare.outputs.match == 'false'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore: upgrade Strapi to ${{ steps.latest-version.outputs.latest }}'
title: 'chore: upgrade Strapi to ${{ steps.latest-version.outputs.latest }}'
body: |
This PR automatically upgrades Strapi packages to the latest version.

- **Current version**: ${{ steps.current-version.outputs.current }}
- **Latest version**: ${{ steps.latest-version.outputs.latest }}

Packages upgraded:
- `@strapi/strapi`
- `@strapi/plugin-users-permissions`
- `@strapi/plugin-cloud`
branch: chore/upgrade-strapi-${{ steps.latest-version.outputs.latest }}
delete-branch: true
labels: |
dependencies
automated

8 changes: 4 additions & 4 deletions demo/.strapi-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"strapi": "strapi"
},
"dependencies": {
"@strapi/plugin-cloud": "latest",
"@strapi/plugin-users-permissions": "latest",
"@strapi/strapi": "latest",
"@strapi/plugin-cloud": "5.31.0",
"@strapi/plugin-users-permissions": "5.31.0",
"@strapi/strapi": "5.31.0",
"better-sqlite3": "11.3.0",
"fs-extra": "^10.0.0",
"mime-types": "^2.1.27",
Expand All @@ -36,4 +36,4 @@
"strapi": {
"uuid": "getstarted"
}
}
}
Loading