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