Skip to content

Commit

Permalink
Add auto-regenerate CI workflow
Browse files Browse the repository at this point in the history
(Splitting shish/safe into smaller parts for easier review)

This adds a cronjob which will re-run the auto-generate scripts and send a PR if any changes have been detected.
  • Loading branch information
shish authored and staabm committed Nov 28, 2024
1 parent 8a6679c commit cf04aca
Showing 1 changed file with 13 additions and 26 deletions.
39 changes: 13 additions & 26 deletions .github/workflows/auto-regenerate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,31 @@ name: "Auto Regenerate"
on:
schedule:
- cron: '0 3 * * *'
workflow_dispatch:

jobs:

auto-regenerate:
name: "Tries to regenerate the files"
runs-on: "ubuntu-latest"
name: "Auto Regenerate"
runs-on: "ubuntu-24.04"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
uses: "actions/checkout@v4"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "8.0"
php-version: "8.3"

- name: "Check out salathe/phpdoc-base"
uses: "actions/checkout@v2"
uses: "actions/checkout@v4"
with:
path: "generator/doc/doc-en/doc-base"
repository: "salathe/phpdoc-base"

- name: "Check out php/doc-en"
uses: "actions/checkout@v2"
uses: "actions/checkout@v4"
with:
path: "generator/doc/doc-en/en"
repository: "php/doc-en"
Expand All @@ -43,33 +44,19 @@ jobs:
run: "composer dump-autoload"

- name: "Regenerate files"
run: "./safe.php generate"
id: regen
run: "./safe.php generate && git diff --exit-code && (echo regen=no-diff >> $GITHUB_OUTPUT) || (echo regen=diff >> $GITHUB_OUTPUT)"
working-directory: "generator"

- name: "Check if regenerated files are different"
run: |
if output=$(git status --porcelain) && [ -z "$output" ]; then
# all is good
echo "Generated files are the same as committed file: OK"
else
# Uncommitted changes
echo "Generated files are different from commited files. Please run './safe.php generate' command and commit the results."
echo "Detected changes:"
git status
git diff
echo "Generated files are different from commited files. Please run './safe.php generate' command and commit the results."
exit 1;
fi
- name: "Create a pr if the files are different"
if: ${{ failure() }}
uses: peter-evans/create-pull-request@v3
if: "${{ steps.regen.outputs.regen == 'diff' }}"
uses: peter-evans/create-pull-request@v6
with:
commit-message: "Automatically regenerate the files"
branch: create-pull-request/regenerate-files
title: "Automatically regenerate the files"
labels: "regenerate, auto"
assignees: "kharhamel, moufmouf"
assignees: "shish, OskarStark, silasjoisten, moufmouf"




0 comments on commit cf04aca

Please sign in to comment.