Skip to content

Commit

Permalink
fix: accurate github tagging (#188)
Browse files Browse the repository at this point in the history
* fix: accurate github tagging

* feat: update
  • Loading branch information
ryan-timothy-albert authored Nov 14, 2024
1 parent 0cae241 commit 57e87e9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions internal/actions/runWorkflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ func RunWorkflow() error {
}
}()

if branchName != "" {
os.Setenv("SPEAKEASY_ACTIVE_BRANCH", branchName)
}

runRes, outputs, err := run.Run(g, pr, wf)
if err != nil {
if err := setOutputs(outputs); err != nil {
Expand Down Expand Up @@ -278,12 +282,44 @@ func finalize(inputs finalizeInputs) error {
}
}

// add merging branch registry tag
if err = addDirectModeBranchTagging(); err != nil {
logging.Debug("failed to tag registry images: %v", err)
}

inputs.Outputs["commit_hash"] = commitHash
}

return nil
}

func addDirectModeBranchTagging() error {
wf, err := configuration.GetWorkflowAndValidateLanguages(true)
if err != nil {
return err
}

branch := strings.TrimPrefix(os.Getenv("GITHUB_REF"), "refs/heads/")

var sources, targets []string
if specificTarget := environment.SpecifiedTarget(); specificTarget != "" {
if target, ok := wf.Targets[environment.SpecifiedTarget()]; ok {
sources = append(sources, target.Source)
targets = append(targets, specificTarget)
}
} else {
for name, target := range wf.Targets {
sources = append(sources, target.Source)
targets = append(targets, name)
}
}
if len(sources) > 0 && len(targets) > 0 && branch != "" {
return cli.Tag([]string{branch}, sources, targets)
}

return nil
}

func getReleasesInfo() (*releases.ReleasesInfo, error) {
releasesDir, err := getReleasesDir()
if err != nil {
Expand Down

0 comments on commit 57e87e9

Please sign in to comment.