dosubot[bot] commented on issue #7698:
URL:
https://github.com/apache/incubator-devlake/issues/7698#issuecomment-2210368640
<!-- Greeting -->
@IgorIgnatevSky Hello! I'm here to help you with any issues you may have
with the repository. I can assist with bug fixes, answer your questions, and
guide you on becoming a contributor. If you need any assistance, feel free to
ask!
<!-- Answer -->
To address the issue where the `name` column in the `_tool_github_runs` and
`cicd_pipelines` tables contains the `display_title` instead of the workflow
name when `run-name` is defined in a GitHub Actions workflow, you need to
modify the logic that populates the `name` field. Specifically, you should set
the `name` field to the workflow name if `run-name` is defined, otherwise, use
the `display_title`.
Here is a possible approach to achieve this:
1. Modify the `GithubRun` struct to include a method that sets the `name`
field based on the presence of `run-name`.
2. Update the logic where the `GithubRun` instances are created or updated
to call this method.
Here is an example of how you might implement this:
```go
package archived
import (
"github.com/apache/incubator-devlake/core/models/migrationscripts/archived"
"time"
)
type GithubRun struct {
ConnectionId uint64 `gorm:"primaryKey"`
RepoId int `gorm:"primaryKey"`
ID int64 `json:"id"
gorm:"primaryKey;autoIncrement:false"`
Name string `json:"name" gorm:"type:varchar(255)"`
NodeID string `json:"node_id" gorm:"type:varchar(255)"`
HeadBranch string `json:"head_branch"
gorm:"type:varchar(255)"`
HeadSha string `json:"head_sha" gorm:"type:varchar(255)"`
Path string `json:"path" gorm:"type:varchar(255)"`
RunNumber int `json:"run_number"`
Event string `json:"event" gorm:"type:varchar(255)"`
Status string `json:"status" gorm:"type:varchar(255)"`
Conclusion string `json:"conclusion" gorm:"type:varchar(255)"`
WorkflowID int `json:"workflow_id"`
CheckSuiteID int64 `json:"check_suite_id"`
CheckSuiteNodeID string `json:"check_suite_node_id"
gorm:"type:varchar(255)"`
URL string `json:"url" gorm:"type:varchar(255)"`
HTMLURL string `json:"html_url" gorm:"type:varchar(255)"`
GithubCreatedAt *time.Time `json:"created_at"`
GithubUpdatedAt *time.Time `json:"updated_at"`
RunAttempt int `json:"run_attempt"`
RunStartedAt *time.Time `json:"run_started_at"`
JobsURL string `json:"jobs_url" gorm:"type:varchar(255)"`
LogsURL string `json:"logs_url" gorm:"type:varchar(255)"`
CheckSuiteURL string `json:"check_suite_url"
gorm:"type:varchar(255)"`
ArtifactsURL string `json:"artifacts_url"
gorm:"type:varchar(255)"`
CancelURL string `json:"cancel_url" gorm:"type:varchar(255)"`
RerunURL string `json:"rerun_url" gorm:"type:varchar(255)"`
WorkflowURL string `json:"workflow_url"
gorm:"type:varchar(255)"`
Type string `json:"type" gorm:"type:varchar(255)"`
archived.NoPKModel
}
func (run *GithubRun) SetName(workflowName string, runName string) {
if runName != "" {
run.Name = runName
} else {
run.Name = workflowName
}
}
func (GithubRun) TableName() string {
return "_tool_github_runs"
}
```
In the code where you create or update `GithubRun` instances, you would call
the `SetName` method:
```go
// Example function to create or update a GithubRun
func createOrUpdateGithubRun(workflowName string, runName string,
otherParams ...) {
run := &GithubRun{
// set other fields
}
run.SetName(workflowName, runName)
// save run to the database
}
```
This ensures that the `name` field is set to the workflow name if `run-name`
is not defined, otherwise, it uses the `run-name`
<sup>[[1]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/github/models/run.go)</sup><sup>[[2]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/github/models/migrationscripts/archived/run.go)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]