Skip to content

Commit

Permalink
Add draft version of the GitHub Action
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hayakawa <hhiroshell@gmail.com>
  • Loading branch information
hhiroshell committed Mar 6, 2024
1 parent 2a12d6f commit 11b247f
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/deep-diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# This script lists files that have been added or edited under a specified directory,
# including the targets of any symlinks.

set -e

if [ "$#" -ne 1 ] && [ "$#" -ne 3 ]; then
echo "The number of arguments must be either 1 or 3."
echo "Usage: ./list-targets.sh [path] <[commit] [commit]>"
exit 1
fi

if [ "$#" -eq 1 ]; then
git diff --name-only "$1"
else
git diff --name-only "$2" "$3" "$1"
fi

# Differences in targets of symbolic links.
symlinks=$(find "$1" -type l)
for l in ${symlinks}; do
linktarget=$(readlink -f "${l}")

if [ "$#" -eq 1 ]; then
git diff --name-only "$(realpath --relative-to=. "${linktarget}")"
else
git diff --name-only "$2" "$3" "$(realpath --relative-to=. "${linktarget}")"
fi
done
41 changes: 41 additions & 0 deletions .github/workflows/notice-i18n-tasks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Notice i18n Tasks
on:
pull_request:
types:
- opened
- reopened
- synchronize

jobs:
notice-i18n-tasks:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name : Check the diffs when the issue is opened
id: diff-check-opened
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: |
echo "diff-count=$(.github/workflows/deep-diff.sh hoge | wc -l)" >> $GITHUB_OUTPUT
- name: Check the diffs when the content in the PR updated
id: diff-check-updated
if: github.event.action == 'synchronize'
run: |
echo "diff-count=$(.github/workflows/deep-diff.sh hoge ${{ github.event.before }} ${{ github.event.after }} | wc -l)" >> $GITHUB_OUTPUT
- name: Send notice on the issue
if: steps.diff-check-opened.outputs.diff-count > 0 || steps.diff-check-updated.outputs.diff-count > 0
uses: thollander/actions-comment-pull-request@v2
with:
message: |
### Action Required
You are adding or updating English content so please take the following actions for other languages.
- 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.)
- If you update the content in the same location, please perform the following actions for the corresponding content in other languages.
- If the content has not been translated yet, replace the files with the updated English version.
- If the content has already been translated, include a note suggesting that users check the English page for the most recent updates.

0 comments on commit 11b247f

Please sign in to comment.