diff --git a/.github/workflows/discord-discussion-comments.yml b/.github/workflows/discord-discussion-comments.yml new file mode 100644 index 000000000000..29d7528bbfcb --- /dev/null +++ b/.github/workflows/discord-discussion-comments.yml @@ -0,0 +1,45 @@ +name: Discord Integration - Discussion Comments +on: + discussion_comment: + types: [created] + +jobs: + post-to-discord: + name: Post Comment To Discord + runs-on: ubuntu-latest + steps: + - name: Build Embeds JSON + env: + TEMPLATE: >- + [{ + "author": { + "name": $author_name, + "icon_url": $author_icon_url, + "url": $author_html_url + }, + "title": $title, + "color": 2369839, + "url": $html_url, + "description": $body, + "footer": { + "text": $repo_full_name + } + }] + AUTHOR: ${{ github.event.sender.login }} + AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} + AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} + TITLE: 'Comment on #${{ github.event.discussion.number }} ${{ github.event.discussion.title }}' + BODY: ${{ github.event.comment.body }} + HTML_URL: ${{ github.event.review.html_url }} + REPO_FULL_NAME: ${{ github.event.repository.full_name }} + run: | + echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg html_url "$HTML_URL" --arg body "$BODY" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV + - name: Send Notification + uses: Ilshidur/action-discord@0.3.2 + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_DISCUSSIONS_WEBHOOK }} + DISCORD_USERNAME: 'GitHub' + DISCORD_AVATAR: https://octodex.github.com/images/socialite.jpg + SENDER_NAME: ${{ github.event.sender.login }} + with: + args: 'New comment by ${{ env.SENDER_NAME }}' diff --git a/.github/workflows/discord-discussion-opened.yml b/.github/workflows/discord-discussion-opened.yml new file mode 100644 index 000000000000..1b9a0201f574 --- /dev/null +++ b/.github/workflows/discord-discussion-opened.yml @@ -0,0 +1,47 @@ +name: Discord Integration - Discussion Opened +on: + discussion: + types: [opened] + +jobs: + post-to-discord: + name: Post Notification To Discord + runs-on: ubuntu-latest + steps: + - name: Build Embeds JSON + env: + TEMPLATE: >- + [{ + "author": { + "name": $author_name, + "icon_url": $author_icon_url, + "url": $author_html_url + }, + "title": $title, + "color": 3581519, + "url": $html_url, + "description": $description, + "footer": { + "text": $repo_full_name + } + }] + AUTHOR: ${{ github.event.sender.login }} + AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} + AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} + TITLE: '#${{ github.event.discussion.number }} ${{ github.event.discussion.title }}' + HTML_URL: ${{ github.event.discussion.html_url }} + DESCRIPTION: ${{ github.event.discussion.body }} + REPO_FULL_NAME: ${{ github.event.repository.full_name }} + run: | + # This provides the env variable used by the next step + # We have to do it like this to prevent any of the values screwing up the json + echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg html_url "$HTML_URL" --arg description "$DESCRIPTION" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV + - name: Send Notification + uses: Ilshidur/action-discord@0.3.2 + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_DISCUSSIONS_WEBHOOK }} + DISCORD_USERNAME: 'GitHub' + DISCORD_AVATAR: https://octodex.github.com/images/socialite.jpg + SENDER_NAME: ${{ github.event.sender.login }} + with: + args: 'Discussion started by ${{ env.SENDER_NAME }}' diff --git a/.github/workflows/discord-issue-closed.yml b/.github/workflows/discord-issue-closed.yml new file mode 100644 index 000000000000..e281ee650bb3 --- /dev/null +++ b/.github/workflows/discord-issue-closed.yml @@ -0,0 +1,47 @@ +name: Discord Integration - Issue Closed +on: + issues: + types: [closed] + +jobs: + post-to-discord: + name: Post Notification To Discord + runs-on: ubuntu-latest + steps: + - name: Build Embeds JSON + env: + TEMPLATE: >- + [{ + "author": { + "name": $author_name, + "icon_url": $author_icon_url, + "url": $author_html_url + }, + "title": $title, + "color": 13313073, + "url": $html_url, + "description": $description, + "footer": { + "text": $repo_full_name + } + }] + AUTHOR: ${{ github.event.sender.login }} + AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} + AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} + TITLE: 'Closed #${{ github.event.issue.number }} ${{ github.event.issue.title }}' + HTML_URL: ${{ github.event.issue.html_url }} + DESCRIPTION: ${{ github.event.issue.body }} + REPO_FULL_NAME: ${{ github.event.repository.full_name }} + run: | + # This provides the env variable used by the next step + # We have to do it like this to prevent any of the values screwing up the json + echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg html_url "$HTML_URL" --arg description "$DESCRIPTION" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV + - name: Send Notification + uses: Ilshidur/action-discord@0.3.2 + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_ISSUES_WEBHOOK }} + DISCORD_USERNAME: 'GitHub' + DISCORD_AVATAR: https://octodex.github.com/images/original.png + SENDER_NAME: ${{ github.event.sender.login }} + with: + args: 'Issue closed by ${{ env.SENDER_NAME }}' diff --git a/.github/workflows/discord-issue-comments.yml b/.github/workflows/discord-issue-comments.yml new file mode 100644 index 000000000000..d0f5387013ec --- /dev/null +++ b/.github/workflows/discord-issue-comments.yml @@ -0,0 +1,46 @@ +name: Discord Integration - Issue Comments +on: + issue_comment: + types: [created] + +jobs: + post-to-discord: + name: Post Comment To Discord + runs-on: ubuntu-latest + if: ${{ !github.event.issue.pull_request }} + steps: + - name: Build Embeds JSON + env: + TEMPLATE: >- + [{ + "author": { + "name": $author_name, + "icon_url": $author_icon_url, + "url": $author_html_url + }, + "title": $title, + "color": 2369839, + "url": $html_url, + "description": $body, + "footer": { + "text": $repo_full_name + } + }] + AUTHOR: ${{ github.event.sender.login }} + AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} + AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} + TITLE: 'Comment on #${{ github.event.issue.number }} ${{ github.event.issue.title }}' + BODY: ${{ github.event.comment.body }} + HTML_URL: ${{ github.event.review.html_url }} + REPO_FULL_NAME: ${{ github.event.repository.full_name }} + run: | + echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg html_url "$HTML_URL" --arg body "$BODY" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV + - name: Send Notification + uses: Ilshidur/action-discord@0.3.2 + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_ISSUES_WEBHOOK }} + DISCORD_USERNAME: 'GitHub' + DISCORD_AVATAR: https://octodex.github.com/images/original.png + SENDER_NAME: ${{ github.event.sender.login }} + with: + args: 'New comment by ${{ env.SENDER_NAME }}' diff --git a/.github/workflows/discord-issue-opened.yml b/.github/workflows/discord-issue-opened.yml new file mode 100644 index 000000000000..f56a74f671ea --- /dev/null +++ b/.github/workflows/discord-issue-opened.yml @@ -0,0 +1,47 @@ +name: Discord Integration - Issue Opened +on: + issues: + types: [opened] + +jobs: + post-to-discord: + name: Post Notification To Discord + runs-on: ubuntu-latest + steps: + - name: Build Embeds JSON + env: + TEMPLATE: >- + [{ + "author": { + "name": $author_name, + "icon_url": $author_icon_url, + "url": $author_html_url + }, + "title": $title, + "color": 3581519, + "url": $html_url, + "description": $description, + "footer": { + "text": $repo_full_name + } + }] + AUTHOR: ${{ github.event.sender.login }} + AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} + AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} + TITLE: '#${{ github.event.issue.number }} ${{ github.event.issue.title }}' + HTML_URL: ${{ github.event.issue.html_url }} + DESCRIPTION: ${{ github.event.issue.body }} + REPO_FULL_NAME: ${{ github.event.repository.full_name }} + run: | + # This provides the env variable used by the next step + # We have to do it like this to prevent any of the values screwing up the json + echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg html_url "$HTML_URL" --arg description "$DESCRIPTION" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV + - name: Send Notification + uses: Ilshidur/action-discord@0.3.2 + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_ISSUES_WEBHOOK }} + DISCORD_USERNAME: 'GitHub' + DISCORD_AVATAR: https://octodex.github.com/images/original.png + SENDER_NAME: ${{ github.event.sender.login }} + with: + args: 'Issue opened by ${{ env.SENDER_NAME }}' diff --git a/.github/workflows/discord-pr-closed.yml b/.github/workflows/discord-pr-closed.yml new file mode 100644 index 000000000000..36ccfe714e92 --- /dev/null +++ b/.github/workflows/discord-pr-closed.yml @@ -0,0 +1,61 @@ +name: Discord Integration - PR Closed +on: + pull_request: + types: [closed] + +jobs: + post-to-discord: + name: Post Notification To Discord + runs-on: ubuntu-latest + steps: + - name: Build Merged Args + if: ${{ github.event.pull_request.merged }} + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + SENDER_NAME: ${{ github.event.sender.login }} + run: | + echo "TITLE=Merged #$PR_NUMBER $PR_TITLE" >> $GITHUB_ENV + echo "COLOR=7291585" >> $GITHUB_ENV + echo "MESSAGE_ARGS=PR merged by $SENDER_NAME'" >> $GITHUB_ENV + - name: Build Closed Args + if: ${{ !github.event.pull_request.merged }} + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + SENDER_NAME: ${{ github.event.sender.login }} + run: | + echo "TITLE=Closed (Without Merge) #$PR_NUMBER $PR_TITLE" >> $GITHUB_ENV + echo "COLOR=13313073" >> $GITHUB_ENV + echo "MESSAGE_ARGS=PR closed by $SENDER_NAME" >> $GITHUB_ENV + - name: Build Embeds JSON + env: + TEMPLATE: >- + [{ + "author": { + "name": $author_name, + "icon_url": $author_icon_url, + "url": $author_html_url + }, + "title": $title, + "color": $color, + "url": $html_url, + "footer": { + "text": $repo_full_name + } + }] + AUTHOR: ${{ github.event.sender.login }} + AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} + AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} + HTML_URL: ${{ github.event.pull_request.html_url }} + REPO_FULL_NAME: ${{ github.event.repository.full_name }} + run: | + echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg color "$COLOR" --arg html_url "$HTML_URL" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV + - name: Send Notification + uses: Ilshidur/action-discord@0.3.2 + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_PRS_WEBHOOK }} + DISCORD_USERNAME: 'GitHub' + DISCORD_AVATAR: https://octodex.github.com/images/inspectocat.jpg + with: + args: ${{ env.MESSAGE_ARGS }} diff --git a/.github/workflows/discord-pr-comments.yml b/.github/workflows/discord-pr-comments.yml new file mode 100644 index 000000000000..1158c6fd0fe6 --- /dev/null +++ b/.github/workflows/discord-pr-comments.yml @@ -0,0 +1,66 @@ +name: Discord Integration - PR Comments +on: + pull_request_review_comment: + types: [created] + issue_comment: + types: [created] + +jobs: + post-to-discord: + name: Post Notification To Discord + runs-on: ubuntu-latest + if: ${{ github.event.pull_request || github.event.issue.pull_request }} + steps: + - name: Capture Body With Diff + if: ${{ github.event.comment.diff_hunk }} + env: + BASE_DIFF_HUNK: ${{ github.event.comment.diff_hunk }} + BODY: ${{ github.event.comment.body }} + run: echo "BODY=\`\`\`$BASE_DIFF_HUNK\`\`\`\n$BODY" >> $GITHUB_ENV + - name: Build PR Review Comment Args + if: ${{ github.event.pull_request }} + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + echo "TITLE=Comment on #$PR_NUMBER $PR_TITLE" >> $GITHUB_ENV + - name: Build PR Issue Comment Args + if: ${{ github.event.issue.pull_request }} + env: + PR_NUMBER: ${{ github.event.issue.number }} + PR_TITLE: ${{ github.event.issue.title }} + run: | + echo "TITLE=Comment on #$PR_NUMBER $PR_TITLE" >> $GITHUB_ENV + - name: Build Embeds JSON + env: + TEMPLATE: >- + [{ + "author": { + "name": $author_name, + "icon_url": $author_icon_url, + "url": $author_html_url + }, + "title": $title, + "color": 2369839, + "url": $html_url, + "description": $body, + "footer": { + "text": $repo_full_name + } + }] + AUTHOR: ${{ github.event.sender.login }} + AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} + AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} + HTML_URL: ${{ github.event.review.html_url }} + REPO_FULL_NAME: ${{ github.event.repository.full_name }} + run: | + echo "PARTIAL_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg html_url "$HTML_URL" --arg body "$BODY" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV + - name: Send Notification + uses: Ilshidur/action-discord@0.3.2 + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_PRS_WEBHOOK }} + DISCORD_USERNAME: 'GitHub' + DISCORD_AVATAR: https://octodex.github.com/images/inspectocat.jpg + SENDER_NAME: ${{ github.event.sender.login }} + with: + args: 'New comment by ${{ env.SENDER_NAME }}' diff --git a/.github/workflows/discord-pr-opened.yml b/.github/workflows/discord-pr-opened.yml new file mode 100644 index 000000000000..924d11d7e9bc --- /dev/null +++ b/.github/workflows/discord-pr-opened.yml @@ -0,0 +1,49 @@ +name: Discord Integration - PR Opened +on: + pull_request: + types: [opened, ready_for_review] + +jobs: + post-to-discord: + name: Post Notification To Discord + runs-on: ubuntu-latest + if: ${{ !github.event.pull_request.draft }} + steps: + - name: Build Embeds JSON + env: + TEMPLATE: >- + [{ + "author": { + "name": $author_name, + "icon_url": $author_icon_url, + "url": $author_html_url + }, + "title": $title, + "color": 7291585, + "url": $html_url, + "description": $description, + "footer": { + "text": $repo_full_name + } + }] + AUTHOR: ${{ github.event.sender.login }} + AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} + AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} + TITLE: '#${{ github.event.pull_request.number }} ${{ github.event.pull_request.title }}' + HTML_URL: ${{ github.event.pull_request.html_url }} + DESCRIPTION: ${{ github.event.pull_request.body }} + REPO_FULL_NAME: ${{ github.event.repository.full_name }} + run: | + # This provides the env variable used by the next step + # We have to do it like this to prevent any of the values screwing up the json + echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg html_url "$HTML_URL" --arg description "$DESCRIPTION" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV + - name: Send Notification + uses: Ilshidur/action-discord@0.3.2 + env: + BODY: ${{ github.event.pull_request.body }} + DISCORD_WEBHOOK: ${{ secrets.DISCORD_PRS_WEBHOOK }} + DISCORD_USERNAME: 'GitHub' + DISCORD_AVATAR: https://octodex.github.com/images/inspectocat.jpg + SENDER_NAME: ${{ github.event.sender.login }} + with: + args: 'PR opened by ${{ env.SENDER_NAME }}' diff --git a/.github/workflows/discord-pr-review.yml b/.github/workflows/discord-pr-review.yml new file mode 100644 index 000000000000..37a812efab8f --- /dev/null +++ b/.github/workflows/discord-pr-review.yml @@ -0,0 +1,64 @@ +name: Discord Integration - PR Review +on: + pull_request_review: + types: [submitted] + +jobs: + post-to-discord: + name: Post Notification To Discord + runs-on: ubuntu-latest + if: ${{ github.event.review.state == 'approved' || github.event.review.state == 'changes_requested' }} + steps: + - name: Build Approval Args + if: ${{ github.event.review.state == 'approved' }} + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + SENDER_NAME: ${{ github.event.sender.login }} + run: | + echo "TITLE=Approved #$PR_NUMBER $PR_TITLE" >> $GITHUB_ENV + echo "COLOR=3581519" >> $GITHUB_ENV + echo "MESSAGE_ARGS=PR approved by $SENDER_NAME" >> $GITHUB_ENV + - name: Build Changes Requested Args + if: ${{ github.event.review.state == 'changes_requested' }} + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + SENDER_NAME: ${{ github.event.sender.login }} + run: | + echo "TITLE=Changes Requested #$PR_NUMBER $PR_TITLE" >> $GITHUB_ENV + echo "COLOR=13313073" >> $GITHUB_ENV + echo "MESSAGE_ARGS=Changes requested by $SENDER_NAME" >> $GITHUB_ENV + - name: Build Embeds JSON + env: + TEMPLATE: >- + [{ + "author": { + "name": $author_name, + "icon_url": $author_icon_url, + "url": $author_html_url + }, + "title": $title, + "color": $color, + "url": $html_url, + "description": $description, + "footer": { + "text": $repo_full_name + } + }] + AUTHOR: ${{ github.event.sender.login }} + AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} + AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} + HTML_URL: ${{ github.event.review.html_url }} + DESCRIPTION: ${{ github.event.review.body }} + REPO_FULL_NAME: ${{ github.event.repository.full_name }} + run: | + echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg color "$COLOR" --arg html_url "$HTML_URL" --arg description "$DESCRIPTION" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV + - name: Send Notification + uses: Ilshidur/action-discord@0.3.2 + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_PRS_WEBHOOK }} + DISCORD_USERNAME: 'GitHub' + DISCORD_AVATAR: https://octodex.github.com/images/inspectocat.jpg + with: + args: ${{ env.MESSAGE_ARGS }} diff --git a/.github/workflows/master-pushes.yml b/.github/workflows/master-pushes.yml index 1854b0a5fb46..9f0b8bddbf72 100644 --- a/.github/workflows/master-pushes.yml +++ b/.github/workflows/master-pushes.yml @@ -59,7 +59,7 @@ jobs: if: steps.cache-editor-tests.outputs.cache-hit != 'true' run: nix-shell --arg includeServerBuildSupport false --arg includeRunLocallySupport false --run check-editor-all-ci - name: Discord Notification - uses: Ilshidur/action-discord@0.3.0 + uses: Ilshidur/action-discord@0.3.2 if: failure() env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_BUILD_WEBHOOK }} @@ -111,7 +111,7 @@ jobs: if: steps.cache-editor-tests.outputs.cache-hit != 'true' run: nix-shell --arg includeServerBuildSupport false --arg includeRunLocallySupport false --run test-editor-move-template-only-ci - name: Discord Notification - uses: Ilshidur/action-discord@0.3.0 + uses: Ilshidur/action-discord@0.3.2 if: failure() env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_BUILD_WEBHOOK }} @@ -157,7 +157,7 @@ jobs: if: steps.cache-server-tests.outputs.cache-hit != 'true' run: nix-shell --arg includeEditorBuildSupport false --arg includeRunLocallySupport false --run test-server-ci - name: Discord Notification - uses: Ilshidur/action-discord@0.3.0 + uses: Ilshidur/action-discord@0.3.2 if: failure() env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_BUILD_WEBHOOK }}