Skip to content

Commit 332792f

Browse files
committed
CI: check the EN-Revision hash of changed files
1 parent 08e5b7a commit 332792f

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# https://docs.github.com/en/actions
2+
# Checks that the EN-Revision comment of the .xml files changed in a PR points to
3+
# the latest doc-en commit for that file. Emits a ::error annotation and fails if
4+
# the hash is missing, wrong, from another file, or outdated.
5+
6+
name: "Check EN-Revision"
7+
8+
on:
9+
pull_request:
10+
branches: ["master"]
11+
types: [opened, synchronize]
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
revision:
18+
name: "EN-Revision"
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: "Checkout translation"
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: "Checkout php/doc-en"
27+
uses: actions/checkout@v4
28+
with:
29+
path: en
30+
repository: php/doc-en
31+
fetch-depth: 0
32+
33+
- name: "Check EN-Revision"
34+
run: |
35+
BASE="${{ github.event.pull_request.base.sha }}"
36+
git fetch --no-tags --depth=1 origin "$BASE"
37+
fail=0
38+
while IFS= read -r f; do
39+
[ -f "$f" ] && [ -f "en/$f" ] || continue
40+
declared=$(grep -oiP 'EN-Revision:\s*\K[0-9a-f]+' "$f" | head -1 || true)
41+
latest=$(git -C en log -1 --format=%H -- "$f")
42+
if [ "$declared" != "$latest" ]; then
43+
echo "::error file=$f::EN-Revision ${declared:-missing} != latest doc-en commit $latest"
44+
fail=1
45+
fi
46+
done < <(git diff --name-only "$BASE"...HEAD -- '*.xml')
47+
exit $fail

0 commit comments

Comments
 (0)