From e669192f5f34122f252958686319b19be58cbf13 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 30 Sep 2024 15:30:23 +0200 Subject: [PATCH 01/22] debug job and steps, and don't push br to latest tag --- .github/workflows/ci.yml | 1 - cmd/gh-action/gh.go | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8aab40..e1bd155 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,4 +35,3 @@ jobs: with: platforms: linux/amd64, linux/arm64 push: true - tags: ${{ vars.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest diff --git a/cmd/gh-action/gh.go b/cmd/gh-action/gh.go index 6823019..811069f 100644 --- a/cmd/gh-action/gh.go +++ b/cmd/gh-action/gh.go @@ -10,6 +10,19 @@ import ( "golang.org/x/oauth2" ) +func printJobInfo(job *github.WorkflowJob) { + fmt.Printf("== Job %s %s, (created: %v, started: %v, completed: %v)\n", + *job.Name, + *job.Status, + *job.CreatedAt, + job.StartedAt, + job.CompletedAt, + ) + for _, step := range job.Steps { + fmt.Printf("Step %s, started %v, completed %v\n", *step.Name, step.StartedAt, step.CompletedAt) + } +} + func createRecords(ctx context.Context, conf configType) (*WorkflowStat, error) { var token *http.Client if len(conf.githubToken) != 0 { @@ -36,6 +49,34 @@ func createRecords(ctx context.Context, conf configType) (*WorkflowStat, error) return &WorkflowStat{RepoName: conf.repository}, nil } + attemptData, _, err := client.Actions.GetWorkflowRunAttempt( + ctx, + conf.owner, conf.repo, + *workflowData.ID, + *workflowData.RunAttempt, + nil, + ) + if err != nil { + return nil, err + } + + // fmt.Printf("AttemptData: %+v\n", attemptData) + + jobsData, _, err := client.Actions.ListWorkflowJobsAttempt( + ctx, + conf.owner, conf.repo, + *attemptData.ID, + int64(*workflowData.RunAttempt), + nil, + ) + if err != nil { + return nil, err + } + fmt.Printf("JobsData: %+v\n", jobsData) + for _, job := range jobsData.Jobs { + printJobInfo(job) + } + return &WorkflowStat{ WorkflowId: *workflowData.ID, Name: *workflowData.Name, From 51101ca37449f58afcb9a8bafb006ef6414973b5 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 30 Sep 2024 15:45:21 +0200 Subject: [PATCH 02/22] use metadata-action for docker tags --- .github/workflows/ci.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1bd155..34c6bae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,17 @@ jobs: docker: runs-on: ubuntu-latest steps: + - name: Docker Meta + id: meta + uses: docker/metadata-action@v6 + with: + images: + ${{ vars.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }} + tags: | + # branch event + type=ref,enable=true,priority=600,prefix=,suffix=,event=branch + # pull request event + type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=pr - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -34,4 +45,6 @@ jobs: uses: docker/build-push-action@v6 with: platforms: linux/amd64, linux/arm64 - push: true + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From d0d7cacf3d86653687693cec98c85203dcd36802 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 30 Sep 2024 15:46:39 +0200 Subject: [PATCH 03/22] mistype --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34c6bae..59a13d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Docker Meta id: meta - uses: docker/metadata-action@v6 + uses: docker/metadata-action@v5 with: images: ${{ vars.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }} From 20a4a1e6891cb1d933eece98c54d08f51946d5d3 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Mon, 30 Sep 2024 16:00:50 +0200 Subject: [PATCH 04/22] push docker image for pr --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 59a13d1..ac9a685 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,6 @@ jobs: uses: docker/build-push-action@v6 with: platforms: linux/amd64, linux/arm64 - push: ${{ github.event_name != 'pull_request' }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From bc4c78749b061d12dfa1c6f4f484dacd28f2e689 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 09:43:36 +0200 Subject: [PATCH 05/22] use getters and use int64 --- cmd/gh-action/data.go | 4 ++-- cmd/gh-action/gh.go | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cmd/gh-action/data.go b/cmd/gh-action/data.go index c5b92a5..60234c3 100644 --- a/cmd/gh-action/data.go +++ b/cmd/gh-action/data.go @@ -9,8 +9,8 @@ type WorkflowStat struct { Name string Status string Conclusion string - RunId int - RunAttempt int + RunId int64 + RunAttempt int64 StartedAt time.Time UpdatedAt time.Time RepoName string diff --git a/cmd/gh-action/gh.go b/cmd/gh-action/gh.go index 811069f..06339b9 100644 --- a/cmd/gh-action/gh.go +++ b/cmd/gh-action/gh.go @@ -39,12 +39,12 @@ func createRecords(ctx context.Context, conf configType) (*WorkflowStat, error) } fmt.Printf("Getting data for %s/%s, runId %d\n", conf.owner, conf.repo, runID) - workflowData, _, err := client.Actions.GetWorkflowRunByID(ctx, conf.owner, conf.repo, runID) + workflowRunData, _, err := client.Actions.GetWorkflowRunByID(ctx, conf.owner, conf.repo, runID) if err != nil { return nil, err } - if workflowData == nil { + if workflowRunData == nil { fmt.Printf("Got nil\n") return &WorkflowStat{RepoName: conf.repository}, nil } @@ -52,8 +52,8 @@ func createRecords(ctx context.Context, conf configType) (*WorkflowStat, error) attemptData, _, err := client.Actions.GetWorkflowRunAttempt( ctx, conf.owner, conf.repo, - *workflowData.ID, - *workflowData.RunAttempt, + *workflowRunData.ID, + *workflowRunData.RunAttempt, nil, ) if err != nil { @@ -66,7 +66,7 @@ func createRecords(ctx context.Context, conf configType) (*WorkflowStat, error) ctx, conf.owner, conf.repo, *attemptData.ID, - int64(*workflowData.RunAttempt), + int64(workflowRunData.GetRunAttempt()), nil, ) if err != nil { @@ -78,15 +78,15 @@ func createRecords(ctx context.Context, conf configType) (*WorkflowStat, error) } return &WorkflowStat{ - WorkflowId: *workflowData.ID, - Name: *workflowData.Name, - Status: *workflowData.Status, - Conclusion: *workflowData.Conclusion, - RunId: *workflowData.RunNumber, - RunAttempt: *workflowData.RunAttempt, - StartedAt: workflowData.CreatedAt.Time, - UpdatedAt: workflowData.UpdatedAt.Time, - RepoName: *workflowData.Repository.FullName, - Event: *workflowData.Event, + WorkflowId: workflowRunData.GetWorkflowID(), + Name: workflowRunData.GetName(), + Status: workflowRunData.GetStatus(), + Conclusion: workflowRunData.GetConclusion(), + RunId: workflowRunData.GetID(), + RunAttempt: int64(workflowRunData.GetRunAttempt()), + StartedAt: workflowRunData.GetCreatedAt().Time, + UpdatedAt: workflowRunData.GetUpdatedAt().Time, + RepoName: workflowRunData.GetRepository().GetFullName(), + Event: workflowRunData.GetEvent(), }, nil } From a83850b0a4515264a56be1571c2435027882116e Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 10:39:46 +0200 Subject: [PATCH 06/22] schemes for tables --- cmd/gh-action/db.go | 49 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/cmd/gh-action/db.go b/cmd/gh-action/db.go index c9275a7..7ea8d6e 100644 --- a/cmd/gh-action/db.go +++ b/cmd/gh-action/db.go @@ -8,7 +8,7 @@ import ( ) var ( - scheme = ` + schemeWorkflowRunsStats = ` CREATE TABLE %s ( workflowid BIGINT, name TEXT, @@ -23,6 +23,51 @@ var ( PRIMARY KEY(workflowid, runattempt) ) ` + schemeWorkflowRuns = ` + CREATE TABLE IF NOT EXISTS %s ( + workflowid BIGINT, + name TEXT, + status TEXT, + conclusion TEXT, + runid INT, + runattempt INT, + startedat TIMESTAMP, + updatedat TIMESTAMP, + reponame TEXT, + event TEXT, + PRIMARY KEY(workflowid, runattempt) + ) + ` + schemeWorkflowJobs = ` + CREATE TABLE IF NOT EXISTS %s ( + JobId BIGINT + RunID BIGINT + NodeID TEXT + HeadBranch TEXT + HeadSHA TEXT + Status TEXT + Conclusion TEXT + CreatedAt TIMESTAMP + StartedAt TIMESTAMP + CompletedAt TIMESTAMP + Name TEXT + RunnerName TEXT + RunnerGroupName TEXT + RunAttempt BIGINT + WorkflowName TEXT + )` + schemeWorkflowJobsSteps = ` + CREATE TABLE IF NOT EXISTS %s ( + JobId BIGINT + RunId BIGINT + Name TEXT + Status TEXT + Conclusion TEXT + Number BIGINT + StartedAt TIMESTAMP + CompletedAt TIMESTAMP + ) + ` ) func initDatabase(conf configType) error { @@ -31,7 +76,7 @@ func initDatabase(conf configType) error { return err } - _, err = db.Exec(fmt.Sprintf(scheme, conf.dbTable)) + _, err = db.Exec(fmt.Sprintf(schemeWorkflowRunsStats, conf.dbTable)) if err != nil { return err } From 580b703f8dbb337ac23ded2c32ea2dd337424fb0 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 11:06:04 +0200 Subject: [PATCH 07/22] refactor db part --- cmd/gh-action/config.go | 4 ++++ cmd/gh-action/db.go | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/gh-action/config.go b/cmd/gh-action/config.go index 60338de..20663e7 100644 --- a/cmd/gh-action/config.go +++ b/cmd/gh-action/config.go @@ -4,11 +4,14 @@ import ( "fmt" "os" "strings" + + "github.com/jmoiron/sqlx" ) type configType struct { dbUri string dbTable string + db *sqlx.DB runID string repository string owner string @@ -47,6 +50,7 @@ func getConfig() (configType, error) { return configType{ dbUri: dbUri, dbTable: dbTable, + db: nil, runID: runID, repository: repository, owner: repoDetails[0], diff --git a/cmd/gh-action/db.go b/cmd/gh-action/db.go index 7ea8d6e..d5d87bc 100644 --- a/cmd/gh-action/db.go +++ b/cmd/gh-action/db.go @@ -83,18 +83,22 @@ func initDatabase(conf configType) error { return nil } -func saveRecords(conf configType, records *WorkflowStat) error { +func connectDB(conf *configType) error { db, err := sqlx.Connect("postgres", conf.dbUri) if err != nil { return err } + conf.db = db + return nil +} +func saveWorkflowRun(conf configType, records *WorkflowStat) error { query := fmt.Sprintf("INSERT INTO %s (%s) VALUES (%s)", conf.dbTable, "workflowid, name, status, conclusion, runid, runattempt, startedAt, updatedAt, repoName, event", ":workflowid, :name, :status, :conclusion, :runid, :runattempt, :startedat, :updatedat, :reponame, :event", ) - _, err = db.NamedExec(query, *records) + _, err := conf.db.NamedExec(query, *records) if err != nil { return err From 8feb6e8bd30607f629bd6b6bfbeaf9ce73b7e23c Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 11:12:54 +0200 Subject: [PATCH 08/22] refactor --- cmd/gh-action/gh.go | 2 +- cmd/gh-action/main.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/gh-action/gh.go b/cmd/gh-action/gh.go index 06339b9..c4b1d97 100644 --- a/cmd/gh-action/gh.go +++ b/cmd/gh-action/gh.go @@ -23,7 +23,7 @@ func printJobInfo(job *github.WorkflowJob) { } } -func createRecords(ctx context.Context, conf configType) (*WorkflowStat, error) { +func getWorkflowStat(ctx context.Context, conf configType) (*WorkflowStat, error) { var token *http.Client if len(conf.githubToken) != 0 { token = oauth2.NewClient(context.Background(), oauth2.StaticTokenSource( diff --git a/cmd/gh-action/main.go b/cmd/gh-action/main.go index d78bacd..311a5c4 100644 --- a/cmd/gh-action/main.go +++ b/cmd/gh-action/main.go @@ -14,13 +14,18 @@ func main() { log.Fatal(err) } - var records *WorkflowStat - records, err = createRecords(ctx, conf) + err = connectDB(&conf) if err != nil { log.Fatal(err) } - err = saveRecords(conf, records) + var workflowStat *WorkflowStat + workflowStat, err = getWorkflowStat(ctx, conf) + if err != nil { + log.Fatal(err) + } + + err = saveWorkflowRun(conf, workflowStat) if err != nil { log.Fatal(err) } From 519c1f7dab315cd613b8ffa6eac2c7e870b3d0a7 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 11:50:19 +0200 Subject: [PATCH 09/22] refactor --- cmd/gh-action/config.go | 2 ++ cmd/gh-action/data.go | 19 ++++++++++++++++++- cmd/gh-action/db.go | 16 ++++++++++++++-- cmd/gh-action/gh.go | 27 +++++++++------------------ cmd/gh-action/main.go | 6 +++++- 5 files changed, 48 insertions(+), 22 deletions(-) diff --git a/cmd/gh-action/config.go b/cmd/gh-action/config.go index 20663e7..2796f6d 100644 --- a/cmd/gh-action/config.go +++ b/cmd/gh-action/config.go @@ -5,6 +5,7 @@ import ( "os" "strings" + "github.com/google/go-github/v65/github" "github.com/jmoiron/sqlx" ) @@ -17,6 +18,7 @@ type configType struct { owner string repo string githubToken string + ghClient *github.Client } func getConfig() (configType, error) { diff --git a/cmd/gh-action/data.go b/cmd/gh-action/data.go index 60234c3..aec184c 100644 --- a/cmd/gh-action/data.go +++ b/cmd/gh-action/data.go @@ -2,9 +2,11 @@ package main import ( "time" + + "github.com/google/go-github/v65/github" ) -type WorkflowStat struct { +type WorkflowRunRec struct { WorkflowId int64 Name string Status string @@ -16,3 +18,18 @@ type WorkflowStat struct { RepoName string Event string } + +func ghWorkflowRunRec(w *github.WorkflowRun) *WorkflowRunRec { + return &WorkflowRunRec{ + WorkflowId: w.GetWorkflowID(), + Name: w.GetName(), + Status: w.GetStatus(), + Conclusion: w.GetConclusion(), + RunId: w.GetID(), + RunAttempt: int64(w.GetRunAttempt()), + StartedAt: w.GetCreatedAt().Time, + UpdatedAt: w.GetUpdatedAt().Time, + RepoName: w.GetRepository().GetFullName(), + Event: w.GetEvent(), + } +} diff --git a/cmd/gh-action/db.go b/cmd/gh-action/db.go index d5d87bc..8a9342b 100644 --- a/cmd/gh-action/db.go +++ b/cmd/gh-action/db.go @@ -5,6 +5,8 @@ import ( "github.com/jmoiron/sqlx" _ "github.com/lib/pq" + + "github.com/google/go-github/v65/github" ) var ( @@ -92,16 +94,26 @@ func connectDB(conf *configType) error { return nil } -func saveWorkflowRun(conf configType, records *WorkflowStat) error { +func saveWorkflowRun(conf configType, record *WorkflowRunRec) error { query := fmt.Sprintf("INSERT INTO %s (%s) VALUES (%s)", conf.dbTable, "workflowid, name, status, conclusion, runid, runattempt, startedAt, updatedAt, repoName, event", ":workflowid, :name, :status, :conclusion, :runid, :runattempt, :startedat, :updatedat, :reponame, :event", ) - _, err := conf.db.NamedExec(query, *records) + _, err := conf.db.NamedExec(query, *record) if err != nil { return err } return nil } + +func saveWorkflowRunAttempt(conf configType, workflowRun *github.WorkflowRun) error { + query := fmt.Sprintf("INSERT INTO %s_attempts (%s) VALUES (%s)", conf.dbTable, + "workflowid, name, status, conclusion, runid, runattempt, startedAt, updatedAt, repoName, event", + ":WorkflowID, :Name, :Status, :Conclusion, :runid, :runattempt, :startedat, :updatedat, :reponame, :event", + ) + + _, err := conf.db.NamedExec(query, ghWorkflowRunRec(workflowRun)) + return err +} diff --git a/cmd/gh-action/gh.go b/cmd/gh-action/gh.go index c4b1d97..56d1fba 100644 --- a/cmd/gh-action/gh.go +++ b/cmd/gh-action/gh.go @@ -23,7 +23,7 @@ func printJobInfo(job *github.WorkflowJob) { } } -func getWorkflowStat(ctx context.Context, conf configType) (*WorkflowStat, error) { +func initGhClient(conf *configType) { var token *http.Client if len(conf.githubToken) != 0 { token = oauth2.NewClient(context.Background(), oauth2.StaticTokenSource( @@ -31,25 +31,27 @@ func getWorkflowStat(ctx context.Context, conf configType) (*WorkflowStat, error )) } - client := github.NewClient(token) + conf.ghClient = github.NewClient(token) +} +func getWorkflowStat(ctx context.Context, conf configType) (*WorkflowRunRec, error) { runID, err := strconv.ParseInt(conf.runID, 10, 64) if err != nil { return nil, err } fmt.Printf("Getting data for %s/%s, runId %d\n", conf.owner, conf.repo, runID) - workflowRunData, _, err := client.Actions.GetWorkflowRunByID(ctx, conf.owner, conf.repo, runID) + workflowRunData, _, err := conf.ghClient.Actions.GetWorkflowRunByID(ctx, conf.owner, conf.repo, runID) if err != nil { return nil, err } if workflowRunData == nil { fmt.Printf("Got nil\n") - return &WorkflowStat{RepoName: conf.repository}, nil + return &WorkflowRunRec{RepoName: conf.repository}, nil } - attemptData, _, err := client.Actions.GetWorkflowRunAttempt( + attemptData, _, err := conf.ghClient.Actions.GetWorkflowRunAttempt( ctx, conf.owner, conf.repo, *workflowRunData.ID, @@ -62,7 +64,7 @@ func getWorkflowStat(ctx context.Context, conf configType) (*WorkflowStat, error // fmt.Printf("AttemptData: %+v\n", attemptData) - jobsData, _, err := client.Actions.ListWorkflowJobsAttempt( + jobsData, _, err := conf.ghClient.Actions.ListWorkflowJobsAttempt( ctx, conf.owner, conf.repo, *attemptData.ID, @@ -77,16 +79,5 @@ func getWorkflowStat(ctx context.Context, conf configType) (*WorkflowStat, error printJobInfo(job) } - return &WorkflowStat{ - WorkflowId: workflowRunData.GetWorkflowID(), - Name: workflowRunData.GetName(), - Status: workflowRunData.GetStatus(), - Conclusion: workflowRunData.GetConclusion(), - RunId: workflowRunData.GetID(), - RunAttempt: int64(workflowRunData.GetRunAttempt()), - StartedAt: workflowRunData.GetCreatedAt().Time, - UpdatedAt: workflowRunData.GetUpdatedAt().Time, - RepoName: workflowRunData.GetRepository().GetFullName(), - Event: workflowRunData.GetEvent(), - }, nil + return ghWorkflowRunRec(workflowRunData), nil } diff --git a/cmd/gh-action/main.go b/cmd/gh-action/main.go index 311a5c4..3abeebc 100644 --- a/cmd/gh-action/main.go +++ b/cmd/gh-action/main.go @@ -19,7 +19,9 @@ func main() { log.Fatal(err) } - var workflowStat *WorkflowStat + initGhClient(&conf) + + var workflowStat *WorkflowRunRec workflowStat, err = getWorkflowStat(ctx, conf) if err != nil { log.Fatal(err) @@ -29,4 +31,6 @@ func main() { if err != nil { log.Fatal(err) } + + // lastAttemptRun, err = getWorkflowAttempt(ctx, conf, workflowStat.RunAttempt) } From 57027047a44684dbeb6eeb37ec8594ebbf6d838e Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 11:56:00 +0200 Subject: [PATCH 10/22] refactor --- cmd/gh-action/config.go | 12 +++++++++--- cmd/gh-action/gh.go | 10 ++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/gh-action/config.go b/cmd/gh-action/config.go index 2796f6d..cb1d4fe 100644 --- a/cmd/gh-action/config.go +++ b/cmd/gh-action/config.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os" + "strconv" "strings" "github.com/google/go-github/v65/github" @@ -13,7 +14,7 @@ type configType struct { dbUri string dbTable string db *sqlx.DB - runID string + runID int64 repository string owner string repo string @@ -37,10 +38,15 @@ func getConfig() (configType, error) { return configType{}, fmt.Errorf("missing env: GITHUB_REPOSITORY") } - runID := os.Getenv("GH_RUN_ID") - if len(runID) == 0 { + envRunID := os.Getenv("GH_RUN_ID") + var runID int64 + if len(envRunID) == 0 { return configType{}, fmt.Errorf("missing env: GH_RUN_ID") } + runID, err := strconv.ParseInt(envRunID, 10, 64) + if err != nil { + return configType{}, fmt.Errorf("GH_RUN_ID must be integer, error: %v", err) + } githubToken := os.Getenv("GH_TOKEN") diff --git a/cmd/gh-action/gh.go b/cmd/gh-action/gh.go index 56d1fba..da702de 100644 --- a/cmd/gh-action/gh.go +++ b/cmd/gh-action/gh.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "net/http" - "strconv" "github.com/google/go-github/v65/github" "golang.org/x/oauth2" @@ -35,13 +34,8 @@ func initGhClient(conf *configType) { } func getWorkflowStat(ctx context.Context, conf configType) (*WorkflowRunRec, error) { - runID, err := strconv.ParseInt(conf.runID, 10, 64) - if err != nil { - return nil, err - } - - fmt.Printf("Getting data for %s/%s, runId %d\n", conf.owner, conf.repo, runID) - workflowRunData, _, err := conf.ghClient.Actions.GetWorkflowRunByID(ctx, conf.owner, conf.repo, runID) + fmt.Printf("Getting data for %s/%s, runId %d\n", conf.owner, conf.repo, conf.runID) + workflowRunData, _, err := conf.ghClient.Actions.GetWorkflowRunByID(ctx, conf.owner, conf.repo, conf.runID) if err != nil { return nil, err } From 8d6a17ef1b59b799d05ea2f20b01cc183b432eb9 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 12:01:38 +0200 Subject: [PATCH 11/22] refactor and save last attempt workflow run --- cmd/gh-action/gh.go | 14 ++++++++++++++ cmd/gh-action/main.go | 9 ++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cmd/gh-action/gh.go b/cmd/gh-action/gh.go index da702de..41088de 100644 --- a/cmd/gh-action/gh.go +++ b/cmd/gh-action/gh.go @@ -75,3 +75,17 @@ func getWorkflowStat(ctx context.Context, conf configType) (*WorkflowRunRec, err return ghWorkflowRunRec(workflowRunData), nil } + +func getWorkflowAttempt(ctx context.Context, conf configType, attempt int64) (*github.WorkflowRun, error) { + workflowRunData, _, err := conf.ghClient.Actions.GetWorkflowRunAttempt( + ctx, + conf.owner, conf.repo, + conf.runID, + int(attempt), + nil, + ) + if err != nil { + return nil, err + } + return workflowRunData, nil +} diff --git a/cmd/gh-action/main.go b/cmd/gh-action/main.go index 3abeebc..e70f34e 100644 --- a/cmd/gh-action/main.go +++ b/cmd/gh-action/main.go @@ -3,6 +3,8 @@ package main import ( "context" "log" + + "github.com/google/go-github/v65/github" ) func main() { @@ -32,5 +34,10 @@ func main() { log.Fatal(err) } - // lastAttemptRun, err = getWorkflowAttempt(ctx, conf, workflowStat.RunAttempt) + var lastAttemptRun *github.WorkflowRun + lastAttemptRun, err = getWorkflowAttempt(ctx, conf, workflowStat.RunAttempt) + if err != nil { + log.Fatal(err) + } + saveWorkflowRunAttempt(conf, lastAttemptRun) } From f6e4c651ee0b1f0baf30d019301782dd2e25f058 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 12:32:24 +0200 Subject: [PATCH 12/22] fatal on failed save attempts --- cmd/gh-action/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/gh-action/main.go b/cmd/gh-action/main.go index e70f34e..a0a45d7 100644 --- a/cmd/gh-action/main.go +++ b/cmd/gh-action/main.go @@ -39,5 +39,8 @@ func main() { if err != nil { log.Fatal(err) } - saveWorkflowRunAttempt(conf, lastAttemptRun) + err = saveWorkflowRunAttempt(conf, lastAttemptRun) + if err != nil { + log.Fatal(err) + } } From bd12aeca1cf30dd5e2c5f43ed1e7450050f6aa27 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 12:58:57 +0200 Subject: [PATCH 13/22] init database --- cmd/gh-action/db.go | 14 +++++++------- cmd/gh-action/main.go | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/gh-action/db.go b/cmd/gh-action/db.go index 8a9342b..4820111 100644 --- a/cmd/gh-action/db.go +++ b/cmd/gh-action/db.go @@ -11,7 +11,7 @@ import ( var ( schemeWorkflowRunsStats = ` - CREATE TABLE %s ( + CREATE TABLE IF NOT EXISTS %s ( workflowid BIGINT, name TEXT, status TEXT, @@ -25,19 +25,19 @@ var ( PRIMARY KEY(workflowid, runattempt) ) ` - schemeWorkflowRuns = ` + schemeWorkflowRunAttempts = ` CREATE TABLE IF NOT EXISTS %s ( workflowid BIGINT, name TEXT, status TEXT, conclusion TEXT, - runid INT, + runid BIGINT, runattempt INT, startedat TIMESTAMP, updatedat TIMESTAMP, reponame TEXT, event TEXT, - PRIMARY KEY(workflowid, runattempt) + PRIMARY KEY(workflowid, runid, runattempt) ) ` schemeWorkflowJobs = ` @@ -73,12 +73,12 @@ var ( ) func initDatabase(conf configType) error { - db, err := sqlx.Connect("postgres", conf.dbUri) + _, err := conf.db.Exec(fmt.Sprintf(schemeWorkflowRunsStats, conf.dbTable)) if err != nil { return err } - _, err = db.Exec(fmt.Sprintf(schemeWorkflowRunsStats, conf.dbTable)) + _, err = conf.db.Exec(fmt.Sprintf(schemeWorkflowRunAttempts, conf.dbTable + "_attempts")) if err != nil { return err } @@ -111,7 +111,7 @@ func saveWorkflowRun(conf configType, record *WorkflowRunRec) error { func saveWorkflowRunAttempt(conf configType, workflowRun *github.WorkflowRun) error { query := fmt.Sprintf("INSERT INTO %s_attempts (%s) VALUES (%s)", conf.dbTable, "workflowid, name, status, conclusion, runid, runattempt, startedAt, updatedAt, repoName, event", - ":WorkflowID, :Name, :Status, :Conclusion, :runid, :runattempt, :startedat, :updatedat, :reponame, :event", + ":workflowid, :name, :status, :conclusion, :runid, :runattempt, :startedat, :updatedat, :reponame, :event", ) _, err := conf.db.NamedExec(query, ghWorkflowRunRec(workflowRun)) diff --git a/cmd/gh-action/main.go b/cmd/gh-action/main.go index a0a45d7..6366c49 100644 --- a/cmd/gh-action/main.go +++ b/cmd/gh-action/main.go @@ -20,6 +20,10 @@ func main() { if err != nil { log.Fatal(err) } + err = initDatabase(conf) + if err != nil { + log.Fatal(err) + } initGhClient(&conf) From 47e5573963a08b3aa6661ce33961cead0944accd Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 13:17:53 +0200 Subject: [PATCH 14/22] create jobs and steps tables --- cmd/gh-action/db.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/gh-action/db.go b/cmd/gh-action/db.go index 4820111..862cc1c 100644 --- a/cmd/gh-action/db.go +++ b/cmd/gh-action/db.go @@ -82,6 +82,16 @@ func initDatabase(conf configType) error { if err != nil { return err } + + _, err = conf.db.Exec(fmt.Sprintf(schemeWorkflowJobs, conf.dbTable + "_jobs")) + if err != nil { + return err + } + + _, err = conf.db.Exec(fmt.Sprintf(schemeWorkflowJobsSteps, conf.dbTable + "_steps")) + if err != nil { + return err + } return nil } From 7414d5c6e2312735817ceb0ff69f0fcb94dbf7d5 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 13:59:32 +0200 Subject: [PATCH 15/22] save jobs info --- cmd/gh-action/data.go | 38 ++++++++++++++++++++++++++++++++++++++ cmd/gh-action/db.go | 38 ++++++++++++++++++++++++-------------- cmd/gh-action/gh.go | 14 ++++++++++++++ cmd/gh-action/main.go | 11 ++++++++++- 4 files changed, 86 insertions(+), 15 deletions(-) diff --git a/cmd/gh-action/data.go b/cmd/gh-action/data.go index aec184c..36eb8ce 100644 --- a/cmd/gh-action/data.go +++ b/cmd/gh-action/data.go @@ -33,3 +33,41 @@ func ghWorkflowRunRec(w *github.WorkflowRun) *WorkflowRunRec { Event: w.GetEvent(), } } + +type WorkflowJobRec struct { + JobId int64 + RunId int64 + NodeID string + HeadBranch string + HeadSHA string + Status string + Conclusion string + CreatedAt time.Time + StartedAt time.Time + CompletedAt time.Time + Name string + RunnerName string + RunnerGroupName string + RunAttempt int64 + WorkflowName string +} + +func ghWorkflowJobRec(j *github.WorkflowJob) *WorkflowJobRec { + return &WorkflowJobRec{ + JobId: j.GetID(), + RunId: j.GetRunID(), + NodeID: j.GetNodeID(), + HeadBranch: j.GetHeadBranch(), + HeadSHA: j.GetHeadSHA(), + Status: j.GetStatus(), + Conclusion: j.GetConclusion(), + CreatedAt: j.GetCreatedAt().Time, + StartedAt: j.GetStartedAt().Time, + CompletedAt: j.GetCompletedAt().Time, + Name: j.GetName(), + RunnerName: j.GetRunnerName(), + RunnerGroupName: j.GetRunnerGroupName(), + RunAttempt: j.GetRunAttempt(), + WorkflowName: j.GetWorkflowName(), + } +} diff --git a/cmd/gh-action/db.go b/cmd/gh-action/db.go index 862cc1c..5a7248c 100644 --- a/cmd/gh-action/db.go +++ b/cmd/gh-action/db.go @@ -42,20 +42,20 @@ var ( ` schemeWorkflowJobs = ` CREATE TABLE IF NOT EXISTS %s ( - JobId BIGINT - RunID BIGINT - NodeID TEXT - HeadBranch TEXT - HeadSHA TEXT - Status TEXT - Conclusion TEXT - CreatedAt TIMESTAMP - StartedAt TIMESTAMP - CompletedAt TIMESTAMP - Name TEXT - RunnerName TEXT - RunnerGroupName TEXT - RunAttempt BIGINT + JobId BIGINT, + RunID BIGINT, + NodeID TEXT, + HeadBranch TEXT, + HeadSHA TEXT, + Status TEXT, + Conclusion TEXT, + CreatedAt TIMESTAMP, + StartedAt TIMESTAMP, + CompletedAt TIMESTAMP, + Name TEXT, + RunnerName TEXT, + RunnerGroupName TEXT, + RunAttempt BIGINT, WorkflowName TEXT )` schemeWorkflowJobsSteps = ` @@ -127,3 +127,13 @@ func saveWorkflowRunAttempt(conf configType, workflowRun *github.WorkflowRun) er _, err := conf.db.NamedExec(query, ghWorkflowRunRec(workflowRun)) return err } + +func saveJobInfo(conf configType, workflowJob *github.WorkflowJob) error { + query := fmt.Sprintf("INSERT INTO %s_jobs (%s) VALUES (%s)", conf.dbTable, + "jobid, runid, nodeid, headbranch, headsha, status, conclustion, createdat, startedat, completedat, name, runnername, runnergroupname, runattempt, workflowname", + ":jobid, :runid, :nodeid, :headbranch, :headsha, :status, :conclustion, :createdat, :startedat, :completedat, :name, :runnername, :runnergroupname, :runattempt, :workflowname", + ) + + _, err := conf.db.NamedExec(query, ghWorkflowJobRec(workflowJob)) + return err +} diff --git a/cmd/gh-action/gh.go b/cmd/gh-action/gh.go index 41088de..3453b13 100644 --- a/cmd/gh-action/gh.go +++ b/cmd/gh-action/gh.go @@ -89,3 +89,17 @@ func getWorkflowAttempt(ctx context.Context, conf configType, attempt int64) (*g } return workflowRunData, nil } + +func getWorkflowAttemptJobs(ctx context.Context, conf configType, attempt int64) ([]*github.WorkflowJob, error) { + jobsData, _, err := conf.ghClient.Actions.ListWorkflowJobsAttempt( + ctx, + conf.owner, conf.repo, + conf.runID, + attempt, + nil, + ) + if err != nil { + return nil, err + } + return jobsData.Jobs, nil +} diff --git a/cmd/gh-action/main.go b/cmd/gh-action/main.go index 6366c49..20d9322 100644 --- a/cmd/gh-action/main.go +++ b/cmd/gh-action/main.go @@ -39,7 +39,8 @@ func main() { } var lastAttemptRun *github.WorkflowRun - lastAttemptRun, err = getWorkflowAttempt(ctx, conf, workflowStat.RunAttempt) + lastAttemptN := workflowStat.RunAttempt + lastAttemptRun, err = getWorkflowAttempt(ctx, conf, lastAttemptN) if err != nil { log.Fatal(err) } @@ -47,4 +48,12 @@ func main() { if err != nil { log.Fatal(err) } + + jobsInfo, err := getWorkflowAttemptJobs(ctx, conf, lastAttemptN) + if err != nil { + log.Fatal(err) + } + for _, jobInfo := range jobsInfo { + saveJobInfo(conf, jobInfo) + } } From 288dbffa842dac88677c439cd1bdd830aeb4b5d5 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 14:01:13 +0200 Subject: [PATCH 16/22] fix query --- cmd/gh-action/db.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/gh-action/db.go b/cmd/gh-action/db.go index 5a7248c..43dfb60 100644 --- a/cmd/gh-action/db.go +++ b/cmd/gh-action/db.go @@ -60,13 +60,13 @@ var ( )` schemeWorkflowJobsSteps = ` CREATE TABLE IF NOT EXISTS %s ( - JobId BIGINT - RunId BIGINT - Name TEXT - Status TEXT - Conclusion TEXT - Number BIGINT - StartedAt TIMESTAMP + JobId BIGINT, + RunId BIGINT, + Name TEXT, + Status TEXT, + Conclusion TEXT, + Number BIGINT, + StartedAt TIMESTAMP, CompletedAt TIMESTAMP ) ` From 90def4c03c153be6f6e0cd1586aa566a89f9d8b7 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 14:11:58 +0200 Subject: [PATCH 17/22] fix table columns --- cmd/gh-action/db.go | 4 ++-- cmd/gh-action/main.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/gh-action/db.go b/cmd/gh-action/db.go index 43dfb60..f046d37 100644 --- a/cmd/gh-action/db.go +++ b/cmd/gh-action/db.go @@ -130,8 +130,8 @@ func saveWorkflowRunAttempt(conf configType, workflowRun *github.WorkflowRun) er func saveJobInfo(conf configType, workflowJob *github.WorkflowJob) error { query := fmt.Sprintf("INSERT INTO %s_jobs (%s) VALUES (%s)", conf.dbTable, - "jobid, runid, nodeid, headbranch, headsha, status, conclustion, createdat, startedat, completedat, name, runnername, runnergroupname, runattempt, workflowname", - ":jobid, :runid, :nodeid, :headbranch, :headsha, :status, :conclustion, :createdat, :startedat, :completedat, :name, :runnername, :runnergroupname, :runattempt, :workflowname", + "jobid, runid, nodeid, headbranch, headsha, status, conclusion, createdat, startedat, completedat, name, runnername, runnergroupname, runattempt, workflowname", + ":jobid, :runid, :nodeid, :headbranch, :headsha, :status, :conclusion, :createdat, :startedat, :completedat, :name, :runnername, :runnergroupname, :runattempt, :workflowname", ) _, err := conf.db.NamedExec(query, ghWorkflowJobRec(workflowJob)) diff --git a/cmd/gh-action/main.go b/cmd/gh-action/main.go index 20d9322..70b0c9b 100644 --- a/cmd/gh-action/main.go +++ b/cmd/gh-action/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "log" "github.com/google/go-github/v65/github" @@ -54,6 +55,9 @@ func main() { log.Fatal(err) } for _, jobInfo := range jobsInfo { - saveJobInfo(conf, jobInfo) + err = saveJobInfo(conf, jobInfo) + if err != nil { + fmt.Println(err) + } } } From d4f6487746fef203c59bff6a057b5260e17e7f2d Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 14:30:59 +0200 Subject: [PATCH 18/22] WorkflowJobStepRec --- cmd/gh-action/data.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/gh-action/data.go b/cmd/gh-action/data.go index 36eb8ce..9ad7049 100644 --- a/cmd/gh-action/data.go +++ b/cmd/gh-action/data.go @@ -71,3 +71,15 @@ func ghWorkflowJobRec(j *github.WorkflowJob) *WorkflowJobRec { WorkflowName: j.GetWorkflowName(), } } + +type WorkflowJobStepRec struct { + JobId int64 + RunId int64 + RunAttempt int64 + Name string + Status string + Conclusion string + Number int64 + StartedAt time.Time + CompletedAt time.Time +} From f28556f97cb86c1b384fc574ce03c345fb43e89f Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 14:46:42 +0200 Subject: [PATCH 19/22] save steps --- cmd/gh-action/data.go | 86 +++++++++++++++++++++++++------------------ cmd/gh-action/db.go | 21 +++++++++++ 2 files changed, 71 insertions(+), 36 deletions(-) diff --git a/cmd/gh-action/data.go b/cmd/gh-action/data.go index 9ad7049..bd7e08b 100644 --- a/cmd/gh-action/data.go +++ b/cmd/gh-action/data.go @@ -35,51 +35,65 @@ func ghWorkflowRunRec(w *github.WorkflowRun) *WorkflowRunRec { } type WorkflowJobRec struct { - JobId int64 - RunId int64 - NodeID string - HeadBranch string - HeadSHA string - Status string - Conclusion string - CreatedAt time.Time - StartedAt time.Time - CompletedAt time.Time - Name string - RunnerName string + JobId int64 + RunId int64 + NodeID string + HeadBranch string + HeadSHA string + Status string + Conclusion string + CreatedAt time.Time + StartedAt time.Time + CompletedAt time.Time + Name string + RunnerName string RunnerGroupName string - RunAttempt int64 - WorkflowName string + RunAttempt int64 + WorkflowName string } func ghWorkflowJobRec(j *github.WorkflowJob) *WorkflowJobRec { return &WorkflowJobRec{ - JobId: j.GetID(), - RunId: j.GetRunID(), - NodeID: j.GetNodeID(), - HeadBranch: j.GetHeadBranch(), - HeadSHA: j.GetHeadSHA(), - Status: j.GetStatus(), - Conclusion: j.GetConclusion(), - CreatedAt: j.GetCreatedAt().Time, - StartedAt: j.GetStartedAt().Time, - CompletedAt: j.GetCompletedAt().Time, - Name: j.GetName(), - RunnerName: j.GetRunnerName(), + JobId: j.GetID(), + RunId: j.GetRunID(), + NodeID: j.GetNodeID(), + HeadBranch: j.GetHeadBranch(), + HeadSHA: j.GetHeadSHA(), + Status: j.GetStatus(), + Conclusion: j.GetConclusion(), + CreatedAt: j.GetCreatedAt().Time, + StartedAt: j.GetStartedAt().Time, + CompletedAt: j.GetCompletedAt().Time, + Name: j.GetName(), + RunnerName: j.GetRunnerName(), RunnerGroupName: j.GetRunnerGroupName(), - RunAttempt: j.GetRunAttempt(), - WorkflowName: j.GetWorkflowName(), + RunAttempt: j.GetRunAttempt(), + WorkflowName: j.GetWorkflowName(), } } type WorkflowJobStepRec struct { - JobId int64 - RunId int64 - RunAttempt int64 - Name string - Status string - Conclusion string - Number int64 - StartedAt time.Time + JobId int64 + RunId int64 + RunAttempt int64 + Name string + Status string + Conclusion string + Number int64 + StartedAt time.Time CompletedAt time.Time } + +func ghWorkflowJobStepRec(j *github.WorkflowJob, s *github.TaskStep) *WorkflowJobStepRec { + return &WorkflowJobStepRec{ + JobId: j.GetID(), + RunId: j.GetRunID(), + RunAttempt: j.GetRunAttempt(), + Name: s.GetName(), + Status: s.GetStatus(), + Conclusion: s.GetConclusion(), + Number: s.GetNumber(), + StartedAt: s.GetStartedAt().Time, + CompletedAt: s.GetCompletedAt().Time, + } +} diff --git a/cmd/gh-action/db.go b/cmd/gh-action/db.go index f046d37..58b1f71 100644 --- a/cmd/gh-action/db.go +++ b/cmd/gh-action/db.go @@ -62,6 +62,7 @@ var ( CREATE TABLE IF NOT EXISTS %s ( JobId BIGINT, RunId BIGINT, + RunAttempt BIGINT, Name TEXT, Status TEXT, Conclusion TEXT, @@ -135,5 +136,25 @@ func saveJobInfo(conf configType, workflowJob *github.WorkflowJob) error { ) _, err := conf.db.NamedExec(query, ghWorkflowJobRec(workflowJob)) + if err != nil { + return err + } + + for _, step := range workflowJob.Steps { + err = saveStepInfo(conf, workflowJob, step) + if err != nil { + return err + } + } + return nil +} + +func saveStepInfo(conf configType, job *github.WorkflowJob, step *github.TaskStep) error { + query := fmt.Sprintf("INSERT INTO %s_steps (%s) VALUES (%s)", conf.dbTable, + "jobid, runid, runattempt, name, status, conclusion, number, startedat, completead", + ":jobid, :runid, :runattempt, :name, :status, :conclusion, :number, :startedat, :completead", + ) + + _, err := conf.db.Exec(query, ghWorkflowJobStepRec(job, step)) return err } From def64b20c5310288e96e32e89779146f1faedb2c Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 14:48:24 +0200 Subject: [PATCH 20/22] fix --- cmd/gh-action/db.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gh-action/db.go b/cmd/gh-action/db.go index 58b1f71..100d031 100644 --- a/cmd/gh-action/db.go +++ b/cmd/gh-action/db.go @@ -155,6 +155,6 @@ func saveStepInfo(conf configType, job *github.WorkflowJob, step *github.TaskSte ":jobid, :runid, :runattempt, :name, :status, :conclusion, :number, :startedat, :completead", ) - _, err := conf.db.Exec(query, ghWorkflowJobStepRec(job, step)) + _, err := conf.db.NamedExec(query, ghWorkflowJobStepRec(job, step)) return err } From b00a58fb1575cfb2e212d4e23c0d7f7ab8f5bd18 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 14:49:06 +0200 Subject: [PATCH 21/22] fix --- cmd/gh-action/db.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/gh-action/db.go b/cmd/gh-action/db.go index 100d031..940eeaa 100644 --- a/cmd/gh-action/db.go +++ b/cmd/gh-action/db.go @@ -151,8 +151,8 @@ func saveJobInfo(conf configType, workflowJob *github.WorkflowJob) error { func saveStepInfo(conf configType, job *github.WorkflowJob, step *github.TaskStep) error { query := fmt.Sprintf("INSERT INTO %s_steps (%s) VALUES (%s)", conf.dbTable, - "jobid, runid, runattempt, name, status, conclusion, number, startedat, completead", - ":jobid, :runid, :runattempt, :name, :status, :conclusion, :number, :startedat, :completead", + "jobid, runid, runattempt, name, status, conclusion, number, startedat, completedat", + ":jobid, :runid, :runattempt, :name, :status, :conclusion, :number, :startedat, :completedat", ) _, err := conf.db.NamedExec(query, ghWorkflowJobStepRec(job, step)) From 1696a3e0323659454239f8767854c7587edf1b89 Mon Sep 17 00:00:00 2001 From: Fedor Dikarev Date: Fri, 4 Oct 2024 15:22:08 +0200 Subject: [PATCH 22/22] semver for tags and docker image --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac9a685..16f65be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,8 @@ on: push: branches: - main + tags: + - "v*.*.*" permissions: contents: read @@ -29,6 +31,8 @@ jobs: type=ref,enable=true,priority=600,prefix=,suffix=,event=branch # pull request event type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=pr + # tags event + type=semver,pattern={{raw}} - name: Set up QEMU uses: docker/setup-qemu-action@v3