Skip to content

Commit da46bf3

Browse files
authored
Merge pull request #230 from Kharhamel/autoRegenerate
added a workflow to auto regenerate the files
2 parents 9f27717 + 1ccd72b commit da46bf3

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
name: "Auto Regenerate"
3+
4+
on:
5+
branches:
6+
- master
7+
schedule:
8+
- cron: '0 0 * * 0'
9+
10+
jobs:
11+
12+
auto-regenerate:
13+
name: "Continuous Integration"
14+
runs-on: "ubuntu-latest"
15+
steps:
16+
- name: "Checkout"
17+
uses: "actions/checkout@v2"
18+
19+
- name: "Install PHP with extensions"
20+
uses: "shivammathur/setup-php@v2"
21+
with:
22+
coverage: "pcov"
23+
php-version: "7.4"
24+
25+
- name: "Check out salathe/phpdoc-base"
26+
uses: "actions/checkout@v2"
27+
with:
28+
path: "generator/doc/doc-en/doc-base"
29+
repository: "salathe/phpdoc-base"
30+
31+
- name: "Check out php/doc-en"
32+
uses: "actions/checkout@v2"
33+
with:
34+
path: "generator/doc/doc-en/en"
35+
repository: "php/doc-en"
36+
37+
- name: "Install dependencies with composer in generator/ directory"
38+
run: "composer install --no-interaction"
39+
working-directory: "generator"
40+
41+
- name: "Install dependencies with composer in root directory"
42+
run: "composer install --no-interaction"
43+
44+
45+
- name: "Dump autoloader with composer in root directory"
46+
run: "composer dump-autoload"
47+
48+
49+
- name: "Regenerate files"
50+
run: "./safe.php generate"
51+
working-directory: "generator"
52+
53+
- name: "Check if regenerated files are different"
54+
run: |
55+
if output=$(git status --porcelain) && [ -z "$output" ]; then
56+
# all is good
57+
echo "Generated files are the same as committed file: OK"
58+
else
59+
# Uncommitted changes
60+
echo "Generated files are different from commited files. Please run './safe.php generate' command and commit the results."
61+
echo "Detected changes:"
62+
git status
63+
git diff
64+
echo "Generated files are different from commited files. Please run './safe.php generate' command and commit the results."
65+
exit 1;
66+
fi
67+
68+
- name: "Create a pr if the files are different"
69+
if: ${{ failure() }}
70+
uses: peter-evans/create-pull-request@v3
71+
with:
72+
commit-message: "Automatically regenerate the files"
73+
branch: create-pull-request/regenerate-files
74+
title: "Automatically regenerate the files"
75+
labels: "regenerate, auto"
76+
assignees: "kharhamel, moufmouf"
77+
78+
79+

0 commit comments

Comments
 (0)