~emersion/hottub

e4a4b572f2fef67599a7ea70119e2522d23e67dc — Simon Ser 9 months ago 7946187
Set build job visibility
3 files changed, 11 insertions(+), 5 deletions(-)

M buildssrht/gql.go
M buildssrht/operations.graphql
M main.go
M buildssrht/gql.go => buildssrht/gql.go +3 -2
@@ 526,12 526,13 @@ type WebhookTriggerInput struct {
	Url string `json:"url"`
}

func SubmitJob(client *gqlclient.Client, ctx context.Context, manifest string, tags []string, note *string, includeSecrets bool) (submit *Job, err error) {
	op := gqlclient.NewOperation("mutation submitJob ($manifest: String!, $tags: [String!], $note: String, $includeSecrets: Boolean!) {\n\tsubmit(manifest: $manifest, secrets: $includeSecrets, tags: $tags, note: $note) {\n\t\tid\n\t\towner {\n\t\t\tcanonicalName\n\t\t}\n\t}\n}\n")
func SubmitJob(client *gqlclient.Client, ctx context.Context, manifest string, tags []string, note *string, includeSecrets bool, visibility Visibility) (submit *Job, err error) {
	op := gqlclient.NewOperation("mutation submitJob ($manifest: String!, $tags: [String!], $note: String, $includeSecrets: Boolean!, $visibility: Visibility!) {\n\tsubmit(manifest: $manifest, secrets: $includeSecrets, tags: $tags, note: $note, visibility: $visibility) {\n\t\tid\n\t\towner {\n\t\t\tcanonicalName\n\t\t}\n\t}\n}\n")
	op.Var("manifest", manifest)
	op.Var("tags", tags)
	op.Var("note", note)
	op.Var("includeSecrets", includeSecrets)
	op.Var("visibility", visibility)
	var respData struct {
		Submit *Job
	}

M buildssrht/operations.graphql => buildssrht/operations.graphql +2 -2
@@ 1,5 1,5 @@
mutation submitJob($manifest: String!, $tags: [String!], $note: String, $includeSecrets: Boolean!) {
    submit(manifest: $manifest, secrets: $includeSecrets, tags: $tags, note: $note) {
mutation submitJob($manifest: String!, $tags: [String!], $note: String, $includeSecrets: Boolean!, $visibility: Visibility!) {
    submit(manifest: $manifest, secrets: $includeSecrets, tags: $tags, note: $note, visibility: $visibility) {
        id
        owner {
            canonicalName

M main.go => main.go +6 -1
@@ 464,6 464,11 @@ func startJob(ctx *checkSuiteContext, filename string) error {
		tags = append(tags, name)
	}

	visibility := buildssrht.VisibilityPublic
	if *ctx.headRepo.Private {
		visibility = buildssrht.VisibilityPrivate
	}

	commit := ctx.headCommit
	title := strings.SplitN(commit.GetMessage(), "\n", 2)[0]
	shortHash := ctx.headSHA[0:10]


@@ 474,7 479,7 @@ func startJob(ctx *checkSuiteContext, filename string) error {

[%v]: %v`, title, shortHash, commit.Author.GetName(), shortHash, commitURL)

	job, err := buildssrht.SubmitJob(ctx.srht.GQL, ctx, string(manifestBuf), tags, &note, ctx.ownerSubmitted)
	job, err := buildssrht.SubmitJob(ctx.srht.GQL, ctx, string(manifestBuf), tags, &note, ctx.ownerSubmitted, visibility)
	if err != nil {
		return fmt.Errorf("failed to submit sr.ht job: %v", err)
	}