Skip to content

Commit 8de903a

Browse files
authored
Update workflows to check outdated (#1954)
Signed-off-by: Yunkon Kim <[email protected]>
1 parent ec3b0f6 commit 8de903a

File tree

2 files changed

+69
-37
lines changed

2 files changed

+69
-37
lines changed

.github/workflows/check-outdated-terms.yaml renamed to .github/workflows/check-outdated-content.yaml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# This workflow will check if localized terms are outdated or not
2-
# by comparing English terms in the old branch and the latest branch.
3-
name: Check outdated terms
1+
# This workflow will check if a localized content is outdated or not
2+
# by comparing English content in the old branch and the latest branch.
3+
name: Check outdated content
44
on:
55
pull_request:
66
branches:
@@ -9,8 +9,8 @@ on:
99
- 'content/en/**.md'
1010

1111
jobs:
12-
check-outdated-terms:
13-
name: Check outdated terms
12+
check-outdated-content:
13+
name: Check outdated content
1414

1515
# if: contains(fromJSON('["dev-ko", "dev-xx"]'), github.base_ref)
1616
# Ref: https://docs.github.com/en/actions/learn-github-actions/expressions
@@ -41,12 +41,12 @@ jobs:
4141
# Set L10n directory and code
4242
case "${L10N_BRANCH}" in
4343
dev-ko)
44-
L10N_DIR="./content/ko/"
44+
L10N_DIR="content/ko/"
4545
L10N_CODE="ko"
4646
;;
4747
4848
#dev-pt)
49-
#L10N_DIR="./content/pt-br/"
49+
#L10N_DIR="content/pt-br/"
5050
#L10N_CODE="pt"
5151
#;;
5252
esac
@@ -95,16 +95,25 @@ jobs:
9595
# The old branch can be 'upstream/dev-ko'
9696
OLD_BRANCH="origin/${{github.base_ref}}"
9797
echo "(DUBUG) OLD_BRANCH: ${OLD_BRANCH}"
98+
99+
L10N_INFO_JSON=$(cat <<EOF
100+
{
101+
"L10N_DIR": "${L10N_DIR}",
102+
"L10N_CODE": "${L10N_CODE}"
103+
}
104+
EOF
105+
)
98106
99107
# Make an output directory
100108
if [[ ! -e $OUTPUT_DIR ]]; then
101109
mkdir $OUTPUT_DIR
110+
echo "${L10N_INFO_JSON}" > ${OUTPUT_DIR}/L10N_INFO.json
102111
elif [[ ! -d $OUTPUT_DIR ]]; then
103112
echo "$OUTPUT_DIR already exists but is not a directory" 1>&2
104113
fi
105114
106-
# Check outdated only if there is a localized term
107-
# Loop files in a localization directory, which is ${L10N_DIR} (e.g., ./content/ko/)
115+
# Check outdated only if a localized content exists
116+
# Loop files in a localization directory, which is ${L10N_DIR} (e.g., content/ko/)
108117
echo "(DEBUG) Check outdated"
109118
for L10N_FILE_PATH in $(find ${L10N_DIR} -name '*.md'); do
110119
echo "(DEBUG) L10N_FILE_PATH: ${L10N_FILE_PATH}"
@@ -123,7 +132,7 @@ jobs:
123132
# Create subdirectories
124133
mkdir -p ${OUTPUT_DIR}/${FILE_DIR}
125134
126-
# Actually compare between the old and lastest English terms and log diff in the file
135+
# Actually compare between the old and lastest English content and log diff in the file
127136
if [[ -f "./content/en/${FILE_PATH}" ]]; then
128137
# File exists
129138
# Check changes

.github/workflows/post-outdated-terms-report.yaml renamed to .github/workflows/post-outdated-content-report.yaml

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# This workflow will post outdated terms report
1+
# This workflow will post a report of outdated content
22
# by using data from previous workflows.
3-
name: Post outdated terms report
3+
name: Post outdated content report
44

55
on:
66
workflow_run:
7-
workflows: ["Check outdated terms"]
7+
workflows: ["Check outdated content"]
88
types:
99
- completed
1010

1111
jobs:
1212
post-outdated-report:
13-
name: Post outdated terms report
13+
name: Post outdated content report
1414

1515
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1616

@@ -53,37 +53,42 @@ jobs:
5353
uses: dawidd6/action-download-artifact@v2
5454
with:
5555
github_token: ${{secrets.GITHUB_TOKEN}}
56-
workflow: check-outdated-terms.yaml
56+
workflow: check-outdated-content.yaml
5757
workflow_conclusion: success
5858

5959
- name: Set up environment variables from the output
6060
shell: bash
6161
run: |
62+
echo "(DEBUG) Install 'jq' to read json"
63+
sudo apt-get install -y jq
64+
6265
echo "(DEBUG) Display files and directories"
6366
tree
6467
6568
# Set the last changed directory as the output directory
6669
OUTPUT_DIR=$(ls -tp | head -1)
6770
68-
# Extract L10N code from the directory name
69-
# ${MYVAR%%-*}: retain the part before the first '-'
70-
L10N_CODE=${OUTPUT_DIR%%-*}
71+
# Read L10N_DIR and L10N_CODE from L10N_INFO.json
72+
L10N_DIR=$(jq -r '.L10N_DIR' < ${OUTPUT_DIR}/L10N_INFO.json)
73+
L10N_CODE=$(jq -r '.L10N_CODE' < ${OUTPUT_DIR}/L10N_INFO.json)
7174
72-
# Count outdated terms
73-
OUTDATED_TERMS_COUNT=$(ls $OUTPUT_DIR | wc -l)
75+
# Count outdated content
76+
OUTDATED_CONTENT_COUNT=$(ls $OUTPUT_DIR | wc -l)
7477
7578
echo "(DEBUG) OUTPUT_DIR: ${OUTPUT_DIR}"
79+
echo "(DEBUG) L10N_DIR: ${L10N_DIR}"
7680
echo "(DEBUG) L10N_CODE: ${L10N_CODE}"
77-
echo "(DEBUG) OUTDATED_TERMS_COUNT: ${OUTDATED_TERMS_COUNT}"
81+
echo "(DEBUG) OUTDATED_CONTENT_COUNT: ${OUTDATED_CONTENT_COUNT}"
7882
79-
# Set OUTPUT_DIR, L10N_CODE, and OUTDATED_TERMS_COUNT as environment variables
83+
# Set OUTPUT_DIR, L10N_DIR, L10N_CODE, and OUTDATED_CONTENT_COUNT as environment variables
8084
# Ref: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
8185
echo "OUTPUT_DIR=${OUTPUT_DIR}" >> $GITHUB_ENV
86+
echo "L10N_DIR=${L10N_DIR}" >> $GITHUB_ENV
8287
echo "L10N_CODE=${L10N_CODE}" >> $GITHUB_ENV
83-
echo "OUTDATED_TERMS_COUNT=${OUTDATED_TERMS_COUNT}" >> $GITHUB_ENV
88+
echo "OUTDATED_CONTENT_COUNT=${OUTDATED_CONTENT_COUNT}" >> $GITHUB_ENV
8489
8590
- name: Generate a report markdown
86-
if: ${{ env.OUTDATED_TERMS_COUNT > 0 }}
91+
if: ${{ env.OUTDATED_CONTENT_COUNT > 0 }}
8792
shell: bash
8893
run: |
8994
FILE_LIST=$(find ${OUTPUT_DIR} -name '*.md')
@@ -92,39 +97,57 @@ jobs:
9297
touch report.md
9398
9499
# Generate markdown
95-
echo "NOTICE - The following outdated terms must be resolved before the next L10n branch updates." >> report.md
100+
echo "This is an issue to track and reflect updates of English content. Please, check the files below as they may have been improved." >> report.md
101+
echo "" >> report.md
102+
echo "NOTICE - The following outdated content should be resolved before the next L10n branch updates." >> report.md
96103
echo "" >> report.md
97-
echo "### Outdated files" >> report.md
104+
echo "### Files to check" >> report.md
98105
99106
for FILE in ${FILE_LIST}; do
100107
FILE_NAME="${FILE#${OUTPUT_DIR}}"
101-
echo "- ${FILE_NAME}" >> report.md
108+
echo "- [ ] ${FILE_NAME}" >> report.md
102109
done
103110
104111
echo "" >> report.md
105112
106-
echo "### Details" >> report.md
113+
echo "### Changes in each file" >> report.md
107114
108115
for FILE in ${FILE_LIST}; do
109116
FILE_NAME="${FILE#${OUTPUT_DIR}}"
110117
111-
echo "Outdated file: ${FILE_NAME}" >> report.md
112-
echo "" >> report.md
113-
echo "\`\`\`diff" >> report.md
114-
cat ${FILE} >> report.md
115-
echo "\`\`\`" >> report.md
118+
echo "#### ${FILE_NAME}" >> report.md
119+
echo "- en: https://github.com/${{ github.repository }}/blob/main/content/en/${FILE_NAME}" >> report.md
120+
echo "- ${{ env.L10N_CODE }}: https://github.com/${{ github.repository }}/blob/dev-${{ env.L10N_CODE }}/${{ env.L10N_DIR }}${FILE_NAME}" >> report.md
116121
echo "" >> report.md
117-
122+
123+
# The collapsible section is applied to improve the readability of the report.
124+
# Apply collapsible section in case the number of lines is greater than 20.
125+
LINES=$(wc -l < ${FILE})
126+
if [[ "$LINES" -gt "20" ]]; then
127+
echo "<details>" >> report.md
128+
echo "<summary><b>Diff in detail</b></summary>" >> report.md
129+
echo "" >> report.md
130+
echo "\`\`\`diff" >> report.md
131+
cat ${FILE} >> report.md
132+
echo "\`\`\`" >> report.md
133+
echo "</details>" >> report.md
134+
echo "" >> report.md
135+
else
136+
echo "\`\`\`diff" >> report.md
137+
cat ${FILE} >> report.md
138+
echo "\`\`\`" >> report.md
139+
echo "" >> report.md
140+
fi
141+
118142
done
119143
120-
echo "The end of report" >> report.md
144+
echo "The end of report" >> report.md
121145
122146
- name: Create an issue from the report
123147
uses: peter-evans/create-issue-from-file@v4
124148
with:
125-
title: "[${{ env.L10N_CODE }}] A report to track update"
149+
title: "[${{ env.L10N_CODE }}] A report to track and reflect updates of English content"
126150
content-filepath: report.md
127151
labels: |
128152
outdated
129-
good first issue
130153
lang/${{ env.L10N_CODE }}

0 commit comments

Comments
 (0)