Skip to content

Commit

Permalink
feat(ios-action): create runner-task with org-id
Browse files Browse the repository at this point in the history
  • Loading branch information
sfwn committed Jul 5, 2024
1 parent a402016 commit 7109d6c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions actions/ios/1.0/internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Conf struct {
DiceOpenapiPrefix string `env:"DICE_OPENAPI_ADDR" required:"true"`
PipelineTaskID string `env:"PIPELINE_TASK_ID" required:"true"`
PipelineID string `env:"PIPELINE_ID" required:"true"`
DiceOrgID int64 `env:"DICE_ORG_ID" required:"true"`

Commands []string `env:"ACTION_COMMANDS"`
Targets []string `env:"ACTION_TARGETS"`
Expand Down
2 changes: 1 addition & 1 deletion actions/ios/1.0/internal/pkg/build/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func UpdateTaskStatus(cfg conf.Conf, taskID int64, status string) error {
return nil
}

func CreateTask(cfg conf.Conf, req *apistructs.CreateRunnerTaskRequest) (int64, error) {
func CreateTask(cfg conf.Conf, req *CreateRunnerTaskRequest) (int64, error) {
var resp apistructs.CreateRunnerTaskResponse
request := httpclient.New(httpclient.WithCompleteRedirect()).Post(cfg.DiceOpenapiPrefix).
Path(fmt.Sprintf("/api/runner/tasks")).
Expand Down
13 changes: 11 additions & 2 deletions actions/ios/1.0/internal/pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ type RunnerTask struct {
ResultDataUrl string `json:"result_data_url"`
}

type CreateRunnerTaskRequest struct {
apistructs.CreateRunnerTaskRequest
OrgID int64 `json:"org_id"`
}

func Execute() error {

envconf.MustLoad(&cfg)
Expand Down Expand Up @@ -115,15 +120,19 @@ func Execute() error {
}

commands = append(commands, cfg.Commands...)
createReq := &apistructs.CreateRunnerTaskRequest{
createReq := apistructs.CreateRunnerTaskRequest{
JobID: cfg.PipelineTaskLogID,
ContextDataUrl: uploadResult.Data.DownloadURL,
Commands: commands,
WorkDir: strings.Replace(cfg.Context, cfg.PipelineContext+"/", "", -1),
Targets: cfg.Targets,
}
createReqWithOrg := CreateRunnerTaskRequest{
CreateRunnerTaskRequest: createReq,
OrgID: cfg.DiceOrgID,
}

taskID, err := CreateTask(cfg, createReq)
taskID, err := CreateTask(cfg, &createReqWithOrg)
if err != nil {
return err
}
Expand Down

0 comments on commit 7109d6c

Please sign in to comment.