From d0d52396eca35f1b4855a8eca9544e4ffb878c94 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sun, 26 May 2024 18:12:24 +0200 Subject: [PATCH] Add Github Actions Workflow to update City dataset automatically (#48) * Upgrade Workflows to use checkout v4 * Add Workflow to update dataset --- .github/workflows/format_php.yml | 2 +- .github/workflows/scheduled-data-update.yml | 32 +++++++++++++++++++++ .github/workflows/tests.yml | 2 +- .github/workflows/update-changelog.yaml | 2 +- 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/scheduled-data-update.yml diff --git a/.github/workflows/format_php.yml b/.github/workflows/format_php.yml index 0ef2144..c02e081 100644 --- a/.github/workflows/format_php.yml +++ b/.github/workflows/format_php.yml @@ -9,7 +9,7 @@ jobs: php-cs-fixer: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} diff --git a/.github/workflows/scheduled-data-update.yml b/.github/workflows/scheduled-data-update.yml new file mode 100644 index 0000000..521233b --- /dev/null +++ b/.github/workflows/scheduled-data-update.yml @@ -0,0 +1,32 @@ +name: Data Update + +on: + workflow_dispatch: + schedule: + - cron: "0 14 20 * *" + +jobs: + update: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + + - name: Install dependencies + run: composer update --prefer-dist --no-interaction + + - name: Update Dataset + run: php app update-cities-dataset + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + title: 'Cities Dataset has been updated' + branch: data-update diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c4445e3..a171ff2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/update-changelog.yaml b/.github/workflows/update-changelog.yaml index c20834c..a4e024b 100644 --- a/.github/workflows/update-changelog.yaml +++ b/.github/workflows/update-changelog.yaml @@ -10,7 +10,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: main