Skip to content

Test change

Test change #2

# Contribution by Cloud Native Guatemala folks :)
# This workflow will check if a localized content is outdated or not
# by comparing English content in the old branch and the latest branch.
name: Check outdated content
on:
pull_request:
# push:
# branches:
# - main
# paths:
# - 'website/content/en/**'
# push:
# branches:
# - '**'
# pull_request:
## branches:
## - '*'
# paths:
# - 'website/content/en/**'
jobs:
check-outdated-content:
#if: startsWith(github.ref, 'refs/heads/')
name: Check outdated content
runs-on: ubuntu-latest
# permissions:
# issues: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history for all tags and branches
- name: Detecting pending translations
shell: bash
run: |
##### DEBUG section, this will be removed later ###########
ls -al
git status
git branch
# Default environment variables
echo "GITHUB_REF: $GITHUB_REF"
echo "Extract branch: ${GITHUB_REF#refs/}"
# `github` context information
echo "(DEBUG) github.ref: ${{github.ref}}"
echo "(DEBUG) github.head_ref: ${{github.head_ref}}"
echo "(DEBUG) github.base_ref: ${{github.base_ref}}"
#####################################################
OUTPUT_DIR="./outdated"
CONTENT_DIR="website/content"
languages=("es" "zh")
base_lang="en"
cd $CONTENT_DIR
echo "(DEBUG) Current folder: "$(pwd)
for lang in ${languages[@]}; do
touch $lang.txt
done
touch $base_lang.txt
# Make an output directory
if [[ ! -e $OUTPUT_DIR ]]; then
mkdir $OUTPUT_DIR
elif [[ ! -d $OUTPUT_DIR ]]; then
echo "$OUTPUT_DIR already exists but is not a directory" 1>&2
fi
LATEST_BRANCH=${GITHUB_REF#refs/}
echo "(DEBUG) LATEST_BRANCH: ${LATEST_BRANCH}"
# Get the old branch from 'github.base_ref'
# The old branch can be 'upstream/dev-ko'
OLD_BRANCH="origin/${{github.base_ref}}"
echo "(DEBUG) OLD_BRANCH: ${OLD_BRANCH}"
compare () {
FILE_PATH=$1
# Actually compare between the old and latest English content and log diff in the file
if [[ -f "${FILE_PATH}" ]]; then
# File exists
# Check changes
git diff ${OLD_BRANCH}..${LATEST_BRANCH} -- ${FILE_PATH} > temp.diff
if [[ -s "temp.diff" ]]; then
echo "(DEBUG) ${FILE_PATH} is outdated."
mkdir -p ${OUTPUT_DIR}/${FILE_PATH%/*}
mv temp.diff ${OUTPUT_DIR}/${FILE_PATH}
else
echo "check if ${FILE_PATH} exist in other languages"
for lang in ${languages[@]}; do
NEW_FILE_PATH=$(echo "${FILE_PATH}" | sed -e "s/${base_lang}\//${lang}\//g")
if [[ ! -e "${NEW_FILE_PATH}" ]]; then
echo "The file ${FILE_PATH} needs to be translated to $lang"
echo ${NEW_FILE_PATH} >> $lang.txt
fi
done
fi
else
echo "(DEBUG) ${FILE_PATH} does not exist."
fi
}
find $base_lang -iname "*.md" > files.txt
sort files.txt > files_temp.txt;mv files_temp.txt files.txt
INFILE=files.txt
while IFS= read -r line
do
compare "$line"
done < "$INFILE"
find outdated -iname "*.md" | sed -e "s/outdated/website\/content/g" > $base_lang.txt
- name: Generate content for translation issues
id: to_translate
shell: bash
run: |
CONTENT_DIR="website/content"
cd $CONTENT_DIR
echo "(DEBUG) Current folder: "$(pwd)
languages=("es" "zh")
for lang in ${languages[@]}; do
FILES=""
echo -e "*Docs to translate for "$lang" language* <br />\n" > $lang"_files.txt"
while IFS= read -r line
do
FILES+="- $line <br />\n"
done < "$lang.txt"
echo -e $FILES >> $lang"_files.txt"
done
- name: Print files to translate per language
shell: bash
run: |
CONTENT_DIR="website/content"
echo "(DEBUG) Current folder "$(pwd)
echo "(DEBUG) ES files"
echo -e $(cat $CONTENT_DIR/es_files.txt)
echo "(DEBUG) ZH files"
echo -e $(cat $CONTENT_DIR/zh_files.txt)
- uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: website/content/es_files.txt
id: create-issue
assignees: Dianmz, sergioarmgpl

Check failure on line 150 in .github/workflows/check-outdated-content.yml

View workflow run for this annotation

GitHub Actions / Check outdated content

Invalid workflow file

The workflow is not valid. .github/workflows/check-outdated-content.yml (Line: 150, Col: 7): Unexpected value 'assignees' .github/workflows/check-outdated-content.yml (Line: 151, Col: 7): Unexpected value 'milestone'
milestone: 1
update_existing: true
search_existing: all