Skip to content

Commit

Permalink
fix(action.yml): init
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhe421 committed Nov 11, 2024
1 parent e2ff87f commit 0f11595
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 8 deletions.
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: [alanhe421]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: ["https://www.paypal.com/paypalme/alanhe421","https://www.buymeacoffee.com/alanhg","https://github.com/alanhe421/alfred-workflows/blob/master/wechat-award.jpg"] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## About

just use `${{steps.repo-discussion.outputs.count}}` to get repo's discussion-count.

### Example

```yml
...

on:
# Triggers the workflow on push or pull request events but only for the master branch
watch:
action: started

steps:
- name: Discussion Count
id: repo-discussion
uses: alanhe421/repo-discussion-count-action@master

...

```
35 changes: 27 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
name: 'Repo Star Count'
description: 'Get count of Github repository stars'
name: 'Repo Discussion Count'
description: 'Get discussion count of Github repository'
author: 'Alan He'
inputs:
repo:
description: 'Repository Path'
required: false
default: ${{github.repository}}
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: |
star=`curl -s 'https://api.github.com/repos/${{repo}}?page=$i&per_page=100' | jq .stargazers_count`
echo "repoStars=$star" >> $GITHUB_ENV
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'

0 comments on commit 0f11595

Please sign in to comment.