Skip to content

Commit

Permalink
Add GitHub Action to auto-update demo site (#4)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Varga <[email protected]>
  • Loading branch information
duncanmcclean and jasonvarga authored Jun 24, 2024
1 parent f0c487e commit e6ebb9b
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/auto_update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Auto Update

on:
schedule:
- cron: '0 9 * * *' # Every day at 9am
workflow_dispatch:

jobs:
auto_update:
runs-on: ubuntu-latest
name: Auto Update
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3

- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Generate key
run: php artisan key:generate

- name: Get Current Statamic Version
id: current-statamic-version
run: echo "::set-output name=statamic_version::$(composer show statamic/cms | grep 'versions' | grep -o -E '\*\ .+' | cut -d' ' -f2 | cut -d',' -f1;)"

- name: Update Dependencies
run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Get Updated Statamic Version
id: updated-statamic-version
run: echo "::set-output name=statamic_version::$(composer show statamic/cms | grep 'versions' | grep -o -E '\*\ .+' | cut -d' ' -f2 | cut -d',' -f1;)"

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v20
id: verify-changed-files
with:
files: |
composer.json
composer.lock
public/vendor
- name: Open a Pull Request
if: steps.verify-changed-files.outputs.files_changed == 'true' && steps.current-statamic-version.outputs.statamic_version != steps.updated-statamic-version.outputs.statamic_version
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Statamic ${{ steps.updated-statamic-version.outputs.statamic_version }}"
title: "Statamic ${{ steps.updated-statamic-version.outputs.statamic_version }}"
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 }})."
branch: "auto-update-statamic"
base: main

0 comments on commit e6ebb9b

Please sign in to comment.