Skip to content

Commit

Permalink
make sponsorship amount configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
nehzata committed Sep 20, 2023
1 parent 59497ba commit 0f20baa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Flags:
GitHub classis access token with admin:org & user scopes ($GH_CLASSIC_ACCESS_TOKEN).
--entities=ENTITIES,... The GitHub entities to process sponsorships for. First entity in the list is
considered DEFAULT.
--sponsor-amount=1 The amount to donate to each dependency
--wkr-td-disabled Disable worker.
--wkr-animate-disabled Disable worker.
--wkr-donate-disabled Disable worker.
Expand Down
3 changes: 3 additions & 0 deletions cmd/wkr-gh-sponsor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ var cli struct {

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

SponsorAmount wkrghsponsor.SponsorAmount `help:"The amount to donate to each dependency" default:"1"`

WkrTd wkr_config `embed:"" prefix:"wkr-td-"`
WkrAnimate wkr_config `embed:"" prefix:"wkr-animate-"`
WkrDonate wkr_config `embed:"" prefix:"wkr-donate-"`
Expand Down Expand Up @@ -106,6 +108,7 @@ func main() {
kctx.Bind(cli.TdApiKey)
kctx.Bind(cli.GhClassicAccessToken)
kctx.Bind(cli.Entities)
kctx.Bind(cli.SponsorAmount)

// Start the workers
wkrs := []struct {
Expand Down
1 change: 1 addition & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ type TdApiUrl string
type TdApiKey string
type GhAccessToken string
type Entity string
type SponsorAmount int
3 changes: 2 additions & 1 deletion workers/3-donate/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
func New(
db *database.DB,
ghAccesstoken wkrghsponsor.GhAccessToken,
sponsorAmount wkrghsponsor.SponsorAmount,
) workers.Worker {
return func(ctx context.Context) error {
logger := log.FromContext(ctx)
Expand Down Expand Up @@ -57,7 +58,7 @@ func New(
return err
}

amount := githubv4.Int(1)
amount := githubv4.Int(sponsorAmount)
isRecurring := githubv4.Boolean(false)
privacyLevel := githubv4.SponsorshipPrivacy(githubv4.SponsorshipPrivacyPublic)

Expand Down

0 comments on commit 0f20baa

Please sign in to comment.