|
| 1 | +name: Auto Update |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 9 * * *' # Every day at 9am |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + auto_update: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + name: Auto Update |
| 12 | + steps: |
| 13 | + - name: Checkout |
| 14 | + uses: actions/checkout@v3 |
| 15 | + |
| 16 | + - name: Setup PHP |
| 17 | + uses: shivammathur/setup-php@v2 |
| 18 | + with: |
| 19 | + php-version: 8.3 |
| 20 | + |
| 21 | + - name: Copy .env |
| 22 | + run: php -r "file_exists('.env') || copy('.env.example', '.env');" |
| 23 | + |
| 24 | + - name: Install Dependencies |
| 25 | + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist |
| 26 | + |
| 27 | + - name: Generate key |
| 28 | + run: php artisan key:generate |
| 29 | + |
| 30 | + - name: Get Current Statamic Version |
| 31 | + id: current-statamic-version |
| 32 | + run: echo "::set-output name=statamic_version::$(composer show statamic/cms | grep 'versions' | grep -o -E '\*\ .+' | cut -d' ' -f2 | cut -d',' -f1;)" |
| 33 | + |
| 34 | + - name: Update Dependencies |
| 35 | + run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist |
| 36 | + |
| 37 | + - name: Get Updated Statamic Version |
| 38 | + id: updated-statamic-version |
| 39 | + run: echo "::set-output name=statamic_version::$(composer show statamic/cms | grep 'versions' | grep -o -E '\*\ .+' | cut -d' ' -f2 | cut -d',' -f1;)" |
| 40 | + |
| 41 | + - name: Verify Changed files |
| 42 | + uses: tj-actions/verify-changed-files@v20 |
| 43 | + id: verify-changed-files |
| 44 | + with: |
| 45 | + files: | |
| 46 | + composer.json |
| 47 | + composer.lock |
| 48 | + public/vendor |
| 49 | +
|
| 50 | + - name: Open a Pull Request |
| 51 | + if: steps.verify-changed-files.outputs.files_changed == 'true' && steps.current-statamic-version.outputs.statamic_version != steps.updated-statamic-version.outputs.statamic_version |
| 52 | + uses: peter-evans/create-pull-request@v3 |
| 53 | + with: |
| 54 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + commit-message: "Statamic ${{ steps.updated-statamic-version.outputs.statamic_version }}" |
| 56 | + title: "Statamic ${{ steps.updated-statamic-version.outputs.statamic_version }}" |
| 57 | + body: "This pull request updates this site to [Statamic ${{ steps.updated-statamic-version.outputs.statamic_version }}](https://github.com/statamic/cms/releases/${{ steps.updated-statamic-version.outputs.statamic_version }})." |
| 58 | + branch: "auto-update-statamic" |
| 59 | + base: main |
0 commit comments