Skip to content

Commit 3b1a2af

Browse files
authored
Merge pull request #1 from SimonDarksideJ/feature/sponsorsupdate
Update to composite action
2 parents bc7f596 + aa7cab8 commit 3b1a2af

File tree

3 files changed

+27
-32
lines changed

3 files changed

+27
-32
lines changed

.github/workflows/main.yaml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,7 @@ jobs:
3333
env:
3434
GH_TOKEN: ${{ secrets.SPONSORS_TOKEN }}
3535
GH_LOGIN: your-org
36-
run: |
37-
QUERY='query($login:String!){
38-
organization(login:$login){
39-
monthlyEstimatedSponsorsIncomeInCents
40-
sponsorshipsAsMaintainer(first:1){ totalCount }
41-
}
42-
}'
43-
RESP=$(curl -s https://api.github.com/graphql \
44-
-H "Authorization: Bearer $GH_TOKEN" \
45-
-H "Content-Type: application/json" \
46-
-d "{\"query\":\"$QUERY\",\"variables\":{\"login\":\"$GH_LOGIN\"}}")
47-
CENTS=$(echo "$RESP" | jq '.data.organization.monthlyEstimatedSponsorsIncomeInCents // 0')
48-
COUNT=$(echo "$RESP" | jq '.data.organization.sponsorshipsAsMaintainer.totalCount // 0')
49-
jq -n --argjson sum "$CENTS" --argjson count "$COUNT" \
50-
'{ sponsor_sum: ($sum/100|floor), sponsor_count: $count }' \
51-
> website/_data/gh_sponsors.json
36+
uses: ./FetchGHSponsors
5237

5338
- name: Setup .NET Core SDK
5439
uses: actions/setup-dotnet@v4

.github/workflows/pullrequest.yaml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,7 @@ jobs:
3030
env:
3131
GH_TOKEN: ${{ secrets.SPONSORS_TOKEN }}
3232
GH_LOGIN: your-org
33-
run: |
34-
QUERY='query($login:String!){
35-
organization(login:$login){
36-
monthlyEstimatedSponsorsIncomeInCents
37-
sponsorshipsAsMaintainer(first:1){ totalCount }
38-
}
39-
}'
40-
RESP=$(curl -s https://api.github.com/graphql \
41-
-H "Authorization: Bearer $GH_TOKEN" \
42-
-H "Content-Type: application/json" \
43-
-d "{\"query\":\"$QUERY\",\"variables\":{\"login\":\"$GH_LOGIN\"}}")
44-
CENTS=$(echo "$RESP" | jq '.data.organization.monthlyEstimatedSponsorsIncomeInCents // 0')
45-
COUNT=$(echo "$RESP" | jq '.data.organization.sponsorshipsAsMaintainer.totalCount // 0')
46-
jq -n --argjson sum "$CENTS" --argjson count "$COUNT" \
47-
'{ sponsor_sum: ($sum/100|floor), sponsor_count: $count }' \
48-
> website/_data/gh_sponsors.json
33+
uses: ./FetchGHSponsors
4934

5035
- name: Setup .NET Core SDK
5136
uses: actions/setup-dotnet@v4

FetchGHSponsors/action.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Fetch GH Sponsors
2+
description: 'Updates the GitHub spondors list for the Monogame website'
3+
author: 'MonoGame Foundation'
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Fetch
8+
if: runner.os == 'Linux'
9+
run: |
10+
QUERY='query($login:String!){
11+
organization(login:$login){
12+
monthlyEstimatedSponsorsIncomeInCents
13+
sponsorshipsAsMaintainer(first:1){ totalCount }
14+
}
15+
}'
16+
RESP=$(curl -s https://api.github.com/graphql \
17+
-H "Authorization: Bearer $GH_TOKEN" \
18+
-H "Content-Type: application/json" \
19+
-d "{\"query\":\"$QUERY\",\"variables\":{\"login\":\"$GH_LOGIN\"}}")
20+
CENTS=$(echo "$RESP" | jq '.data.organization.monthlyEstimatedSponsorsIncomeInCents // 0')
21+
COUNT=$(echo "$RESP" | jq '.data.organization.sponsorshipsAsMaintainer.totalCount // 0')
22+
jq -n --argjson sum "$CENTS" --argjson count "$COUNT" \
23+
'{ sponsor_sum: ($sum/100|floor), sponsor_count: $count }' \
24+
> website/_data/gh_sponsors.json
25+
shell: bash

0 commit comments

Comments
 (0)