AB#2249 Rework image build pipeline (#326)

* Rework image build pipeline

* Dont cancel workflow runs on main

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2022-08-03 16:01:36 +02:00 committed by GitHub
parent d3435b06a2
commit 5da92d9d8b
22 changed files with 341 additions and 281 deletions

View file

@ -3,6 +3,7 @@ package git
import (
"errors"
"regexp"
"strings"
"time"
git "github.com/go-git/go-git/v5"
@ -77,6 +78,28 @@ func (g *Git) FirstParentWithVersionTag() (revision string, versionTag string, e
return revision, versionTag, nil
}
// ParsedBranchName returns the name of the current branch.
// Special characters are replaced with "-", and the name is lowercased and trimmed to 49 characters.
// This makes sure that the branch name is usable as a GCP image name.
func (g *Git) ParsedBranchName() (string, error) {
commitRef, err := g.repo.Head()
if err != nil {
return "", err
}
rxp, err := regexp.Compile("[^a-zA-Z0-9-]+")
if err != nil {
return "", err
}
branch := strings.ToLower(rxp.ReplaceAllString(commitRef.Name().Short(), "-"))
if len(branch) > 49 {
branch = branch[:49]
}
return strings.TrimSuffix(branch, "-"), nil
}
// tagsByRevisionHash returns a map from revision hash to a list of associated tags.
func (g *Git) tagsByRevisionHash() (map[string][]string, error) {
tags := make(map[string][]string)