-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
33 lines (33 loc) · 1.14 KB
/
action.yml
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
name: 'Repo Discussion Count'
description: 'Get discussion count of Github repository'
author: 'Alan He'
inputs:
repoPath:
description: 'Repository Path'
required: false
default: ${{github.repository}}
token:
description: 'GitHub Token'
required: true
outputs:
discussionCount:
description: "Repo Discussion Count"
value: ${{ steps.repo-discussion.outputs.discussionCount }} # 确保这里的输出名称与下面的一致
runs:
using: composite
steps:
- id: repo-discussion
run: |
OWNER=$(echo "${{ inputs.repoPath }}" | awk -F '/' '{print $1}')
REPO=$(echo "${{ inputs.repoPath }}" | awk -F '/' '{print $2}')
RESPONSE=$(curl -s -H "Authorization: bearer ${{ inputs.token }}" \
-X POST \
-H "Content-Type: application/json" \
-d "{\"query\": \"query { repository(owner: \\\"$OWNER\\\", name: \\\"$REPO\\\") { discussions { totalCount } } }\"}" \
https://api.github.com/graphql)
COUNT=$(echo "$RESPONSE" | jq '.data.repository.discussions.totalCount')
echo "discussionCount=$COUNT" >> $GITHUB_OUTPUT
shell: bash
branding:
icon: 'award'
color: 'blue'