Skip to content

Commit ea078ba

Browse files
committed
Try using dotnet-sponsor CLI for checks
1 parent 49f34c0 commit ea078ba

1 file changed

Lines changed: 44 additions & 4 deletions

File tree

.github/workflows/sponsor.yml

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,54 @@ jobs:
99
sponsor:
1010
runs-on: ubuntu-latest
1111
continue-on-error: true
12-
env:
13-
token: ${{ secrets.DEVLOOPED_TOKEN }}
1412
if: ${{ !endsWith(github.event.sender.login, '[bot]') && github.event.sender.login != github.repository_owner }}
1513
steps:
1614
- name: 🤘 checkout
17-
if: env.token != ''
1815
uses: actions/checkout@v4
19-
16+
17+
- name: ⚙ install
18+
run: dotnet tool update -g dotnet-sponsor --prerelease
19+
20+
- name: 💻 setup
21+
run: |
22+
sponsor --version
23+
pushd ~
24+
git config -f .sponsorlink/.netconfig sponsorlink.id devlooped.sponsors.ci
25+
26+
- name: 🧪 run
27+
run: |
28+
'${{ secrets.GITHUB_TOKEN }}' | sponsor sync ${{ github.repository_owner }} --tos --with-token
29+
if ($LASTEXITCODE -eq -5) {
30+
throw "Can not determine sponsorship with the provided token")
31+
} elseif ($LASTEXITCODE -eq -6) {
32+
Write-Output "User is not sponsoring, skipping"
33+
exit 0
34+
} elseif ($LASTEXITCODE -eq -3) {
35+
Write-Output "${{ github.repository_owner }} is not set up for SponsorLink"
36+
exit 0
37+
} elseif ($LASTEXITCODE -eq -4) {
38+
Write-Output "${{ github.repository_owner }} SponsorLink manifest is invalid"
39+
exit 0
40+
} elseif ($LASTEXITCODE -ne -0) {
41+
Write-Output "Could not determine sponsor status"
42+
exit $LASTEXITCODE
43+
}
44+
45+
$roles = cat ~/.sponsorlink/github/${{ github.repository_owner }}.jwt | jq -R 'split(".") | .[1] | @base64d | fromjson | .roles[]'
46+
if (($roles | jq 'select(. == "team")' -r) -eq "team") {
47+
Write-Output "User is a team member, skipping"
48+
exit 0
49+
} elseif (($roles | jq 'select(. == "contrib")' -r) -eq "contrib") {
50+
Write-Output "User is a contributor!"
51+
} else {
52+
Write-Output "User is a sponsor"
53+
if (($roles | jq 'select(. == "org")' -r) -eq "org") {
54+
Write-Output " (indirectly as a sponsoring organization member)"
55+
} elseif (($roles | jq 'select(. == "user")' -r) -eq "user") {
56+
Write-Output " (as a direct sponsor)"
57+
}
58+
}
59+
2060
- name: 💜 sponsor
2161
if: env.token != ''
2262
uses: devlooped/actions-sponsor@main

0 commit comments

Comments
 (0)