diff options
author | Yasin <a.piri@hotmail.de> | 2024-05-09 00:04:07 +0200 |
---|---|---|
committer | Yasin <a.piri@hotmail.de> | 2024-05-09 00:04:07 +0200 |
commit | 5e88a6277b40a8bbd65b74fe3c40159cb8ca2cb1 (patch) | |
tree | dce5882ae391ee4fb2c30c54f4d2bb726a7767d0 /.github/workflows | |
parent | b73adb121637fd3dcc3768d1ce69558ab0fa5de8 (diff) | |
download | Skyblocker-5e88a6277b40a8bbd65b74fe3c40159cb8ca2cb1.tar.gz Skyblocker-5e88a6277b40a8bbd65b74fe3c40159cb8ca2cb1.tar.bz2 Skyblocker-5e88a6277b40a8bbd65b74fe3c40159cb8ca2cb1.zip |
fix possible translate webhook problem
shortens the description to a length of less than 4096 characters
Diffstat (limited to '.github/workflows')
-rw-r--r-- | .github/workflows/webhook_translate.yml | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/.github/workflows/webhook_translate.yml b/.github/workflows/webhook_translate.yml index 85ed7c3c..9826110c 100644 --- a/.github/workflows/webhook_translate.yml +++ b/.github/workflows/webhook_translate.yml @@ -34,6 +34,37 @@ jobs: shell: bash run: | OUTPUT=$(go run github.com/josephburnett/jd@latest <(git show HEAD^:src/main/resources/assets/skyblocker/lang/en_us.json) <(git show HEAD:src/main/resources/assets/skyblocker/lang/en_us.json) || true) + + MAX_LENGTH=4070 + + if [ "${#OUTPUT}" -gt "$MAX_LENGTH" ]; then + + OUTPUT="${OUTPUT:0:$MAX_LENGTH}" + + LAST_INDEX=-1 + for (( i=${#OUTPUT}-1; i>=0; i-- )); do + if [[ "${OUTPUT:$i:1}" =~ [-+@] ]]; then + LAST_INDEX=$i + break + fi + done + + if [[ $LAST_INDEX -ne -1 && "${OUTPUT:$LAST_INDEX:1}" =~ [-+] ]]; then + + for (( i=LAST_INDEX-1; i>=0; i-- )); do + if [[ "${OUTPUT:$i:1}" == "@" ]]; then + OUTPUT="${OUTPUT:0:i}" + break + fi + done + else + + OUTPUT="${OUTPUT:0:LAST_INDEX}" + fi + fi + + OUTPUT+="..." + OUTPUT="\`\`\`diff $OUTPUT \`\`\`" |