-
-
Notifications
You must be signed in to change notification settings - Fork 27
65 lines (64 loc) · 2.28 KB
/
discord-sync.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Discord Sync 🎮
on:
schedule:
- cron: '* 1 * * *'
workflow_dispatch:
jobs:
update_discord_stats:
strategy:
matrix:
stat: ['stars', 'issues', 'pull_requests']
include:
- stat: 'stars'
NAME: "⭐ Stars"
CHANNEL: '954517855498547282'
JQ: '.data.repository.stargazerCount'
REQUEST: |
query release($owner:String!,$repo:String!) {
repository(owner:$owner,name:$repo) {
stargazerCount
}
}
- stat: 'issues'
NAME: "🔧 Issues"
CHANNEL: '954497399903117323'
JQ: '.data.repository.issues.totalCount'
REQUEST: |
query release($owner:String!,$repo:String!) {
repository(owner:$owner,name:$repo) {
issues(states: OPEN){
totalCount
}
}
}
- stat: 'pull_requests'
NAME: "➕ Pull Requests"
CHANNEL: '954497747527028796'
JQ: '.data.repository.pullRequests.totalCount'
REQUEST: |
query release($owner:String!,$repo:String!) {
repository(owner:$owner,name:$repo) {
pullRequests(states: OPEN){
totalCount
}
}
}
runs-on: ubuntu-latest
name: "${{ matrix.NAME }}"
steps:
- name: Extract repository name
run: |
echo "repository_name=$(echo '${{ github.repository }}' | awk -F / '{print $2}')" >> $GITHUB_ENV
echo "repository_owner=$(echo '${{ github.repository }}' | awk -F / '{print $1}')" >> $GITHUB_ENV
- name: Retrieve data from GitHub API
run: |
echo "metric=$(gh api graphql -F owner=${{ env.repository_owner }} -F repo=${{ env.repository_name }} -f query='${{ matrix.REQUEST }}' --jq '${{ matrix.JQ }}')" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update Discord channel
run: |
curl --request PATCH \
--url https://discord.com/api/v9/channels/${{ matrix.CHANNEL }} \
--header 'Authorization: Bot ${{ secrets.DISCORD_BOT_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{"name": "${{ matrix.NAME }}: ${{ env.metric }}"}'