Skip to content

Commit e04e3e0

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

1 file changed

Lines changed: 48 additions & 4 deletions

File tree

.github/workflows/sponsor.yml

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,58 @@ 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+
shell: pwsh
28+
env:
29+
SPONSORABLE: ${{ secrets.GITHUB_TOKEN }}
30+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
run: |
32+
$env:TOKEN | sponsor sync $env:SPONSORABLE --tos --with-token
33+
if ($LASTEXITCODE -eq -5) {
34+
throw "Can not determine sponsorship with the provided token"
35+
} elseif ($LASTEXITCODE -eq -6) {
36+
Write-Output "User is not sponsoring, skipping"
37+
exit 0
38+
} elseif ($LASTEXITCODE -eq -3) {
39+
Write-Output "$env:SPONSORABLE is not set up for SponsorLink"
40+
exit 0
41+
} elseif ($LASTEXITCODE -eq -4) {
42+
Write-Output "$env:SPONSORABLE SponsorLink manifest is invalid"
43+
exit 0
44+
} elseif ($LASTEXITCODE -ne -0) {
45+
Write-Output "Could not determine sponsor status"
46+
exit $LASTEXITCODE
47+
}
48+
49+
$roles = cat ~/.sponsorlink/github/$env:SPONSORABLE.jwt | jq -R 'split(".") | .[1] | @base64d | fromjson | .roles[]'
50+
if (($roles | jq 'select(. == "team")' -r) -eq "team") {
51+
Write-Output "User is a team member, skipping"
52+
exit 0
53+
} elseif (($roles | jq 'select(. == "contrib")' -r) -eq "contrib") {
54+
Write-Output "User is a contributor!"
55+
} else {
56+
Write-Output "User is a sponsor"
57+
if (($roles | jq 'select(. == "org")' -r) -eq "org") {
58+
Write-Output " (indirectly as a sponsoring organization member)"
59+
} elseif (($roles | jq 'select(. == "user")' -r) -eq "user") {
60+
Write-Output " (as a direct sponsor)"
61+
}
62+
}
63+
2064
- name: 💜 sponsor
2165
if: env.token != ''
2266
uses: devlooped/actions-sponsor@main

0 commit comments

Comments
 (0)