Demo App Strapi Version Check #3
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
| name: 'Demo App Strapi Version Check' | |
| on: | |
| schedule: | |
| - cron: '0 23 */2 * *' # Run every 2 days 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 | |