Skip to content

Commit 0f20baa

Browse files
committed
make sponsorship amount configurable
1 parent 59497ba commit 0f20baa

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Flags:
2222
GitHub classis access token with admin:org & user scopes ($GH_CLASSIC_ACCESS_TOKEN).
2323
--entities=ENTITIES,... The GitHub entities to process sponsorships for. First entity in the list is
2424
considered DEFAULT.
25+
--sponsor-amount=1 The amount to donate to each dependency
2526
--wkr-td-disabled Disable worker.
2627
--wkr-animate-disabled Disable worker.
2728
--wkr-donate-disabled Disable worker.

cmd/wkr-gh-sponsor/main.go

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ var cli struct {
4444

4545
Entities []wkrghsponsor.Entity `help:"The GitHub entities to process sponsorships for. First entity in the list is considered DEFAULT." required:""`
4646

47+
SponsorAmount wkrghsponsor.SponsorAmount `help:"The amount to donate to each dependency" default:"1"`
48+
4749
WkrTd wkr_config `embed:"" prefix:"wkr-td-"`
4850
WkrAnimate wkr_config `embed:"" prefix:"wkr-animate-"`
4951
WkrDonate wkr_config `embed:"" prefix:"wkr-donate-"`
@@ -106,6 +108,7 @@ func main() {
106108
kctx.Bind(cli.TdApiKey)
107109
kctx.Bind(cli.GhClassicAccessToken)
108110
kctx.Bind(cli.Entities)
111+
kctx.Bind(cli.SponsorAmount)
109112

110113
// Start the workers
111114
wkrs := []struct {

types.go

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ type TdApiUrl string
44
type TdApiKey string
55
type GhAccessToken string
66
type Entity string
7+
type SponsorAmount int

workers/3-donate/worker.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
func New(
2727
db *database.DB,
2828
ghAccesstoken wkrghsponsor.GhAccessToken,
29+
sponsorAmount wkrghsponsor.SponsorAmount,
2930
) workers.Worker {
3031
return func(ctx context.Context) error {
3132
logger := log.FromContext(ctx)
@@ -57,7 +58,7 @@ func New(
5758
return err
5859
}
5960

60-
amount := githubv4.Int(1)
61+
amount := githubv4.Int(sponsorAmount)
6162
isRecurring := githubv4.Boolean(false)
6263
privacyLevel := githubv4.SponsorshipPrivacy(githubv4.SponsorshipPrivacyPublic)
6364

0 commit comments

Comments
 (0)