From ec2672d95e0727e75f628c29d86eb43ee7e67e53 Mon Sep 17 00:00:00 2001 From: Yasin Date: Tue, 9 Apr 2024 21:55:09 +0200 Subject: fix translate workflow (#639) fix --- .github/workflows/webhook_translate.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to '.github/workflows/webhook_translate.yml') diff --git a/.github/workflows/webhook_translate.yml b/.github/workflows/webhook_translate.yml index 5d1208fa..1998ee73 100644 --- a/.github/workflows/webhook_translate.yml +++ b/.github/workflows/webhook_translate.yml @@ -15,10 +15,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 2 + fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '1.20' @@ -39,13 +39,14 @@ jobs: OUTPUT="\`\`\`diff $OUTPUT \`\`\`" + OUTPUT=$(jq -Rn --arg str "$OUTPUT" '$str' | sed -E "s|^(['\"])(.*)\1$|\2|g") JSON_PAYLOAD='{ "content": "<@&1134566053138145330>", "embeds": [ { "title": "Something Changed (Click me)", - "description": "'"${OUTPUT//$'\n'/\\n}"'", + "description": "'"${OUTPUT}"'", "url": "https://translate.hysky.de/projects/Skyblocker/skyblocker", "color": 5808639, "image": { @@ -56,4 +57,9 @@ jobs: "attachments": [] }' - curl -H "Content-Type: application/json" --data-binary "$JSON_PAYLOAD" "${{ secrets.DISCORD_TRANSLATE_WEBHOOK }}" + if echo "$JSON_PAYLOAD" | jq . &>/dev/null; then + curl -H "Content-Type: application/json" --data-binary "$JSON_PAYLOAD" "${{ secrets.DISCORD_TRANSLATE_WEBHOOK }}" + else + echo "Error:" + echo "$JSON_PAYLOAD" + fi \ No newline at end of file -- cgit