From 579fe76aa52b0136eae1d95b46c3f919d5053fc4 Mon Sep 17 00:00:00 2001 From: hochan222 Date: Sun, 7 Jul 2024 22:36:02 +0900 Subject: [PATCH 1/2] feat(actions): ko-locale label discord noti webhooks --- .github/workflows/issue-label-noti.yml | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/issue-label-noti.yml diff --git a/.github/workflows/issue-label-noti.yml b/.github/workflows/issue-label-noti.yml new file mode 100644 index 00000000000000..88c3bf388d4911 --- /dev/null +++ b/.github/workflows/issue-label-noti.yml @@ -0,0 +1,52 @@ +name: Label Notification + +on: + issues: + types: [labeled] + +jobs: + send_notification: + runs-on: ubuntu-latest + + steps: + - name: Trim issue body to 3 lines + id: trim_body + run: | + echo "${{ github.event.issue.body }}" | head -n 3 > trimmed_body.txt + echo "TRIMMED_BODY<> $GITHUB_ENV + while IFS= read -r line; do + echo "$line" >> $GITHUB_ENV + done < trimmed_body.txt + echo "EOF" >> $GITHUB_ENV + + - name: Send ko-locale Discord Notification + if: contains(github.event.issue.labels.*.name, 'ko-locale') + env: + TRIMMED_BODY: ${{ env.TRIMMED_BODY }} + run: | + trimmed_body=$(cat trimmed_body.txt) + payload=$(jq -n --arg title "${{ github.event.issue.title }}" \ + --arg url "${{ github.event.issue.html_url }}" \ + --arg body "$trimmed_body" \ + --arg timestamp "${{ github.event.issue.created_at }}" \ + '{ + "content": "", + "embeds": [ + { + "author": { + "name": "KO ISSUE NOTIFICATION", + "icon_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" + }, + "title": $title, + "url": $url, + "description": $body, + "footer": { + "text": "Created at" + }, + "timestamp": $timestamp + } + ] + }') + curl -X POST -H "Content-Type: application/json" \ + -d "$payload" \ + ${{ secrets.DISCORD_INTERNATIONAL_KOREAN_WEBHOOK_URL }} From dd1f1895f2050d2bab4745a4a38ead1990da7cf9 Mon Sep 17 00:00:00 2001 From: hochan Lee Date: Sun, 7 Jul 2024 22:52:35 +0900 Subject: [PATCH 2/2] Update .github/workflows/issue-label-noti.yml --- .github/workflows/issue-label-noti.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-label-noti.yml b/.github/workflows/issue-label-noti.yml index 88c3bf388d4911..b0809ae4eda33f 100644 --- a/.github/workflows/issue-label-noti.yml +++ b/.github/workflows/issue-label-noti.yml @@ -20,7 +20,7 @@ jobs: echo "EOF" >> $GITHUB_ENV - name: Send ko-locale Discord Notification - if: contains(github.event.issue.labels.*.name, 'ko-locale') + if: contains(github.event.issue.labels.*.name, 'l10n-ko') env: TRIMMED_BODY: ${{ env.TRIMMED_BODY }} run: |