Skip to content

Commit 56418e0

Browse files
author
Lian Li
authored
Merge pull request #574 from hhiroshell/notice-i18n-tasks
Introduce a GitHub Action That Sends a Message to a PR to Notify i18n Tasks.
2 parents 3a3bd21 + c51c42c commit 56418e0

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

.github/workflows/deep-diff.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
# This script lists files that have been added or edited under a specified directory,
3+
# including the targets of any symlinks.
4+
5+
set -e
6+
7+
if [ "$#" -ne 3 ]; then
8+
echo "The number of arguments must be 3." >&2
9+
echo "Usage: ./deep-diff.sh [path] [commit-before] [commit-after]" >&2
10+
exit 1
11+
fi
12+
13+
git diff --name-only "$2" "$3" "$1"
14+
15+
# Differences in targets of symbolic links.
16+
symlinks=$(find "$1" -type l)
17+
for l in ${symlinks}; do
18+
linktarget=$(readlink -f "${l}")
19+
git diff --name-only "$2" "$3" "$(realpath --relative-to=. "${linktarget}")"
20+
done
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Notice i18n Tasks
2+
on:
3+
pull_request_target:
4+
types:
5+
- opened
6+
- reopened
7+
- synchronize
8+
9+
jobs:
10+
notice-i18n-tasks:
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
pull-requests: write
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
repository: ${{ github.event.pull_request.head.repo.full_name }}
21+
ref: ${{ github.event.pull_request.head.ref }}
22+
fetch-depth: 0
23+
24+
- name: Check diffs
25+
id: check-diffs
26+
run: |
27+
updated_files="$(.github/workflows/deep-diff.sh website/content/en ${{ github.sha }} ${{ github.event.pull_request.head.sha }})"
28+
echo "${updated_files}" # for debugging
29+
echo "count=$(echo $updated_files | grep -v '^$' | wc -l)" >> $GITHUB_OUTPUT
30+
31+
- name: Send notice on the issue
32+
if: steps.check-diffs.outputs.count > 0
33+
uses: thollander/actions-comment-pull-request@v2
34+
with:
35+
comment_tag: i18n-notice
36+
message: |
37+
### Action Required
38+
You are adding or updating English content so please take the following actions for other languages.
39+
- If you add new content under `website/content/en` or targets of the symbolic links in the same directory, please replicate it in the corresponding directories of all other languages. (e.g. If you create `website/content/en/blog/new-post.md`, you should copy it to `website/content/ja/blog/new-post.md`, etc.)
40+
- If you update the content in the same location, please perform the following actions for the corresponding content in other languages.
41+
- If the content has not been translated yet, replace the files with the updated English version.
42+
- If the content has already been translated, include a note suggesting that users check the English page for the most recent updates.

0 commit comments

Comments
 (0)