-
Notifications
You must be signed in to change notification settings - Fork 13
chore: auto-upgrade demo strapi #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nclsndr
wants to merge
2
commits into
main
Choose a base branch
from
chore/upgrade-demo-strapi
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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']") | ||
| 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 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 installthenpnpm up ...@latestthen, look into thenode_modules/@strapi/strapi/package.jsonto observe a diff, then conditionally make the PR.@Convly @innerdvations can you detail the rationale/preference behind keeping
latestinstead of a pinned version?There was a problem hiding this comment.
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.jsonHaving 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.