|
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 | + 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 | + |
20 | 60 | - name: 💜 sponsor |
21 | 61 | if: env.token != '' |
22 | 62 | uses: devlooped/actions-sponsor@main |
|
0 commit comments