Skip to content

Commit

Permalink
refactor: Update Discord Copilot workflow to fix grammar description …
Browse files Browse the repository at this point in the history
…in registerCommands.js
  • Loading branch information
xuelink committed May 21, 2024
1 parent 16337af commit c9390ab
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/discord_issue_bug_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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')

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
33 changes: 33 additions & 0 deletions .github/workflows/discord_issue_closure.yml
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions .github/workflows/discord_release.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c9390ab

Please sign in to comment.