Skip to content

Cron Update PHP Modules #799

Cron Update PHP Modules

Cron Update PHP Modules #799

name: Cron Update PHP Modules
on:
schedule:
- cron: '0 23 * * *'
workflow_dispatch:
permissions:
contents: read
jobs:
update-composer-modules:
permissions:
contents: write # for peter-evans/create-pull-request to create branch
pull-requests: write # for peter-evans/create-pull-request to create a PR
runs-on: ubuntu-latest
name: Update PHP Modules
strategy:
fail-fast: false
matrix:
BRANCH:
- develop
- 8.1.x
env:
GH_BRANCH: ${{ matrix.BRANCH }}
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv, simplexml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 16
if: env.GH_BRANCH == 'develop'
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.GH_BRANCH }}
- name: Install Composer dependencies
run: |
composer self-update --stable
composer install --prefer-dist
- name: Install NPM dependencies
working-directory: ./tests/UI
run: npm ci
if: env.GH_BRANCH == 'develop'
- name: Execute script for updating modules
run: php .github/workflows/cron_update_modules/script.php ${{ env.GH_BRANCH }}
- name: Execute script for updating modules
working-directory: ./tests/UI
run: npm run check:data:modules
if: env.GH_BRANCH == 'develop'
- name: Update PrestaShop packages
id: updated-packages
run: |
FILE_CONTENT=$(cat cron_php_update_modules.txt)
echo PR_BODY=$FILE_CONTENT >> $GITHUB_OUTPUT
rm cron_php_update_modules.txt
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
if: ${{steps.updated-packages.outputs.PR_BODY}} != ''
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: cron-php-update-modules-${{ env.GH_BRANCH }}
commit-message: Updated PrestaShop Packages
committer: PrestonBot <[email protected]>
author: prestonBot <[email protected]>
title: 'Updated PrestaShop Packages'
body: ${{steps.updated-packages.outputs.PR_BODY}}
base: ${{ env.GH_BRANCH }}
delete-branch: true