diff --git a/.github/workflows/discussion-discord.yml b/.github/workflows/discussion-discord.yml new file mode 100644 index 00000000..0a9af5d7 --- /dev/null +++ b/.github/workflows/discussion-discord.yml @@ -0,0 +1,35 @@ +name: Notify Discord on new discussions + +on: + discussion: + types: [created] + +jobs: + notify: + runs-on: ubuntu-latest + steps: + - name: Post to Discord (development channel) + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_DEVELOPMENT }} + run: | + payload=$(jq -n \ + --arg title "${{ github.event.discussion.title }}" \ + --arg url "${{ github.event.discussion.html_url }}" \ + --arg user "${{ github.event.discussion.user.login }}" \ + --arg repo "${{ github.repository }}" \ + --arg number "#${{ github.event.discussion.number }}" \ + '{ + "username": "GitHub Discussions", + "avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", + "embeds": [ + { + "title": "New discussion: \($number) \($title)", + "url": \($url), + "color": 16776960, + "author": {"name": \($user)}, + "footer": {"text": \($repo)}, + "timestamp": "${{ github.event.discussion.created_at }}" + } + ] + }') + curl -sS -X POST -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" | cat diff --git a/.github/workflows/issue-discord.yml b/.github/workflows/issue-discord.yml new file mode 100644 index 00000000..6a637e6d --- /dev/null +++ b/.github/workflows/issue-discord.yml @@ -0,0 +1,35 @@ +name: Notify Discord on new issues + +on: + issues: + types: [opened] + +jobs: + notify: + runs-on: ubuntu-latest + steps: + - name: Post to Discord (development channel) + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_DEVELOPMENT }} + run: | + payload=$(jq -n \ + --arg title "${{ github.event.issue.title }}" \ + --arg url "${{ github.event.issue.html_url }}" \ + --arg user "${{ github.event.issue.user.login }}" \ + --arg repo "${{ github.repository }}" \ + --arg number "#${{ github.event.issue.number }}" \ + '{ + "username": "GitHub Issues", + "avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", + "embeds": [ + { + "title": "New issue: \($number) \($title)", + "url": \($url), + "color": 3447003, + "author": {"name": \($user)}, + "footer": {"text": \($repo)}, + "timestamp": "${{ github.event.issue.created_at }}" + } + ] + }') + curl -sS -X POST -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" | cat diff --git a/.github/workflows/pr-discord.yml b/.github/workflows/pr-discord.yml new file mode 100644 index 00000000..379e5a9d --- /dev/null +++ b/.github/workflows/pr-discord.yml @@ -0,0 +1,36 @@ +name: Notify Discord on new PRs + +on: + pull_request: + types: [opened] + +jobs: + notify: + runs-on: ubuntu-latest + steps: + - name: Post to Discord (development channel) + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_DEVELOPMENT }} + run: | + payload=$(jq -n \ + --arg title "${{ github.event.pull_request.title }}" \ + --arg url "${{ github.event.pull_request.html_url }}" \ + --arg user "${{ github.event.pull_request.user.login }}" \ + --arg repo "${{ github.repository }}" \ + --arg number "#${{ github.event.pull_request.number }}" \ + '{ + "username": "GitHub Pull Requests", + "avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", + "embeds": [ + { + "title": "New pull request: \($number) \($title)", + "url": \($url), + "color": 3066993, + "author": {"name": \($user)}, + "footer": {"text": \($repo)}, + "timestamp": "${{ github.event.pull_request.created_at }}" + } + ] + }') + curl -sS -X POST -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" | cat + diff --git a/.github/workflows/release-discord.yml b/.github/workflows/release-discord.yml new file mode 100644 index 00000000..f99bc08e --- /dev/null +++ b/.github/workflows/release-discord.yml @@ -0,0 +1,21 @@ +name: Notify Discord on Release + +on: + push: + tags: + - '*' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + # See https://github.com/teneplaysofficial/releasify-action + # and https://dev.to/tene/introducing-releasify-action-announce-github-releases-on-discord-effortlessly-3132 + discordNotification: + runs-on: ubuntu-latest + steps: + - name: Notify via Releasify + uses: teneplaysofficial/releasify-action@v1 + with: + webhook: ${{ secrets.DISCORD_WEBHOOK_ANNOUNCEMENTS }} + username: "ReleaseBot" diff --git a/docs/community/development.md b/docs/community/development.md index 220bbffe..73cbc0d4 100644 --- a/docs/community/development.md +++ b/docs/community/development.md @@ -344,6 +344,25 @@ Then, you can run the script to update the URLs in the codebase. python scripts/validate_links.py --rewrite ``` +## Integrations + +### Discord + +We integrate with our [Discord server](https://discord.gg/NaQ8QPyHtD) to notify about new releases, issues, PRs, and discussions. + +See: +- [`issue-discord.yml`](https://github.com/django-components/django-components/blob/master/.github/workflows/issue-discord.yml) +- [`release-discord.yml`](https://github.com/django-components/django-components/blob/master/.github/workflows/release-discord.yml) +- [`pr-discord.yml`](https://github.com/django-components/django-components/blob/master/.github/workflows/pr-discord.yml) +- [`discussion-discord.yml`](https://github.com/django-components/django-components/blob/master/.github/workflows/discussion-discord.yml) + +See [this tutorial](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) on how to set up the Discord webhooks. + +The Discord webhook URLs are stored as secrets in the GitHub repository. + +- `DISCORD_WEBHOOK_DEVELOPMENT` - For new issues +- `DISCORD_WEBHOOK_ANNOUNCEMENTS` - For new releases + ## Project management ### Project board