|
| 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 | +
|
0 commit comments