From 855117c17d95d8d32df2f5f1a2b42c82078248d7 Mon Sep 17 00:00:00 2001 From: bhc Date: Mon, 29 Apr 2024 13:44:24 +0300 Subject: [PATCH] Add Discord notification workflows for issue closure, issue creation, and release notes --- .github/FUNDING.yml | 14 +++++++ .../\360\237\220\233-bug-report.md" | 41 +++++++++++++++++++ .../\360\237\232\200-feature-request.md" | 20 +++++++++ .../workflows/discord_issue_bug_release.yml | 33 +++++++++++++++ .github/workflows/discord_issue_closure.yml | 33 +++++++++++++++ .github/workflows/discord_release.yml | 37 +++++++++++++++++ 6 files changed, 178 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 ".github/ISSUE_TEMPLATE/\360\237\220\233-bug-report.md" create mode 100644 ".github/ISSUE_TEMPLATE/\360\237\232\200-feature-request.md" create mode 100644 .github/workflows/discord_issue_bug_release.yml create mode 100644 .github/workflows/discord_issue_closure.yml create mode 100644 .github/workflows/discord_release.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..6b864d8 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,14 @@ +# These are supported funding model platforms + +github: [langx] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +polar: # Replace with a single Polar username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git "a/.github/ISSUE_TEMPLATE/\360\237\220\233-bug-report.md" "b/.github/ISSUE_TEMPLATE/\360\237\220\233-bug-report.md" new file mode 100644 index 0000000..24aa360 --- /dev/null +++ "b/.github/ISSUE_TEMPLATE/\360\237\220\233-bug-report.md" @@ -0,0 +1,41 @@ +--- +name: "\U0001F41B Bug Report" +about: Create a report to help us improve +title: "\U0001F41B :" +labels: triage +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: + +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + +- OS: [e.g. iOS] +- Browser [e.g. chrome, safari] +- Version [e.g. 22] + +**Smartphone (please complete the following information):** + +- Device: [e.g. iPhone6] +- OS: [e.g. iOS8.1] +- Browser [e.g. stock browser, safari] +- Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. + +_If you want speed up process of this issue, please send 🚀 as a reaction._ diff --git "a/.github/ISSUE_TEMPLATE/\360\237\232\200-feature-request.md" "b/.github/ISSUE_TEMPLATE/\360\237\232\200-feature-request.md" new file mode 100644 index 0000000..e60be5c --- /dev/null +++ "b/.github/ISSUE_TEMPLATE/\360\237\232\200-feature-request.md" @@ -0,0 +1,20 @@ +--- +name: "\U0001F680 Feature Request" +about: Suggest an idea for this project +title: "\U0001F680 : " +labels: triage +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. + +_If you want speed up process of this issue, please send 🚀 as a reaction._ diff --git a/.github/workflows/discord_issue_bug_release.yml b/.github/workflows/discord_issue_bug_release.yml new file mode 100644 index 0000000..695de4f --- /dev/null +++ b/.github/workflows/discord_issue_bug_release.yml @@ -0,0 +1,33 @@ +name: Discord Notification on Issue Creation + +on: + issues: + types: [labeled] + +jobs: + send-notification: + runs-on: ubuntu-latest + if: contains(github.event.label.name, 'bug') || contains(github.event.label.name, 'feature') || contains(github.event.label.name, 'blog') + steps: + - name: Fetch Issue Details + id: get_issue_details + run: | + API_RESPONSE=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}) + echo "API Response: $API_RESPONSE" + ISSUE_URL=$(echo "$API_RESPONSE" | jq -r '.html_url') + ISSUE_TITLE=$(echo "$API_RESPONSE" | jq -r '.title') + REPO_NAME="${{ github.repository }}" + echo "issue_url=$ISSUE_URL" >> $GITHUB_ENV + echo "issue_title=$ISSUE_TITLE" >> $GITHUB_ENV + echo "repo_name=$REPO_NAME" >> $GITHUB_ENV + + - name: Send Discord Github Issues + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_GITHUB_ISSUES_WEBHOOK }} + ISSUE_URL: ${{ env.issue_url }} + ISSUE_TITLE: ${{ env.issue_title }} + REPO_NAME: ${{ env.repo_name }} + run: | + SUBTITLE="**New Issue:** $ISSUE_TITLE **Repository:** $REPO_NAME" + PAYLOAD=$(jq -n --arg url "<$ISSUE_URL>" --arg st "$SUBTITLE" '{content: ($st + "\n**More:** " + $url)}') + curl -H "Content-Type: application/json" -X POST -d "$PAYLOAD" $DISCORD_WEBHOOK diff --git a/.github/workflows/discord_issue_closure.yml b/.github/workflows/discord_issue_closure.yml new file mode 100644 index 0000000..8d72f06 --- /dev/null +++ b/.github/workflows/discord_issue_closure.yml @@ -0,0 +1,33 @@ +name: Discord Notification on Issue Closure + +on: + issues: + types: [closed] + +jobs: + send-notification: + runs-on: ubuntu-latest + + steps: + - name: Fetch Issue Details + id: get_issue_details + run: | + API_RESPONSE=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}) + echo "API Response: $API_RESPONSE" + ISSUE_URL=$(echo "$API_RESPONSE" | jq -r '.html_url') + ISSUE_TITLE=$(echo "$API_RESPONSE" | jq -r '.title') + REPO_NAME="${{ github.repository }}" + echo "issue_url=$ISSUE_URL" >> $GITHUB_ENV + echo "issue_title=$ISSUE_TITLE" >> $GITHUB_ENV + echo "repo_name=$REPO_NAME" >> $GITHUB_ENV + + - name: Send Discord Github Issues + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_GITHUB_ISSUES_WEBHOOK }} + ISSUE_URL: ${{ env.issue_url }} + ISSUE_TITLE: ${{ env.issue_title }} + REPO_NAME: ${{ env.repo_name }} + run: | + SUBTITLE="✅ **Issue closed:** $ISSUE_TITLE **Repository:** $REPO_NAME" + PAYLOAD=$(jq -n --arg url "<$ISSUE_URL>" --arg st "$SUBTITLE" '{content: ($st + "\n**More:** " + $url)}') + curl -H "Content-Type: application/json" -X POST -d "$PAYLOAD" $DISCORD_WEBHOOK diff --git a/.github/workflows/discord_release.yml b/.github/workflows/discord_release.yml new file mode 100644 index 0000000..ae94bfc --- /dev/null +++ b/.github/workflows/discord_release.yml @@ -0,0 +1,37 @@ +name: Discord Release Notes Notification + +on: + release: + types: [published] + +jobs: + send-release-notes: + runs-on: ubuntu-latest + + steps: + - name: Fetch Release Notes + id: get_release_notes + run: | + API_RESPONSE=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ github.repository }}/releases/latest) + echo "API Response: $API_RESPONSE" + RELEASE_NOTES=$(echo "$API_RESPONSE" | jq -r '.body' | tr -d '\n' | cut -c 1-200) + RELEASE_NOTES="${RELEASE_NOTES}..." + RELEASE_URL=$(echo "$API_RESPONSE" | jq -r '.html_url') + RELEASE_VERSION=$(echo "$API_RESPONSE" | jq -r '.tag_name') + REPO_NAME="${{ github.repository }}" + echo "release_notes=$RELEASE_NOTES" >> $GITHUB_ENV + echo "release_url=$RELEASE_URL" >> $GITHUB_ENV + echo "release_version=$RELEASE_VERSION" >> $GITHUB_ENV + echo "repo_name=$REPO_NAME" >> $GITHUB_ENV + + - name: Send Discord Notification + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_GITHUB_RELEASES_WEBHOOK }} + RELEASE_NOTES: ${{ env.release_notes }} + RELEASE_URL: ${{ env.release_url }} + RELEASE_VERSION: ${{ env.release_version }} + REPO_NAME: ${{ env.repo_name }} + run: | + SUBTITLE="**New Release :** $RELEASE_VERSION **Repository:** $REPO_NAME" + PAYLOAD=$(jq -n --arg rn "$RELEASE_NOTES" --arg url "<$RELEASE_URL>" --arg st "$SUBTITLE" '{content: ($st + "\n" + $rn + "\n**More:** " + $url)}') + curl -H "Content-Type: application/json" -X POST -d "$PAYLOAD" $DISCORD_WEBHOOK