|
9 | 9 | sponsor: |
10 | 10 | runs-on: ubuntu-latest |
11 | 11 | continue-on-error: true |
12 | | - env: |
13 | | - token: ${{ secrets.DEVLOOPED_TOKEN }} |
14 | 12 | if: ${{ !endsWith(github.event.sender.login, '[bot]') && github.event.sender.login != github.repository_owner }} |
15 | 13 | steps: |
16 | 14 | - name: 🤘 checkout |
17 | | - if: env.token != '' |
18 | 15 | 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 | + |
20 | 64 | - name: 💜 sponsor |
21 | 65 | if: env.token != '' |
22 | 66 | uses: devlooped/actions-sponsor@main |
|
0 commit comments