test: update github ref used on e2e oncluster tests (#1917)

This commit is contained in:
Jefferson Ramos 2023-08-09 18:55:35 -03:00 committed by GitHub
parent 89cf6b7a06
commit 399ab7dd17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -4,6 +4,7 @@ package oncluster
import (
"path/filepath"
"regexp"
"strings"
"testing"
@ -32,10 +33,14 @@ Notes:
func resolveGitVars() (gitRepoUrl string, gitRef string) {
// On a GitHub Action (Pull Request) these variables will be set
// https://docs.github.com/en/actions/learn-github-actions/variables
// https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
gitRepo := common.GetOsEnvOrDefault("GITHUB_REPOSITORY", "knative/func")
gitRef = common.GetOsEnvOrDefault("GITHUB_REF", "main")
gitRepoUrl = "https://github.com/" + gitRepo + ".git"
gitRef = common.GetOsEnvOrDefault("GITHUB_REF", "main")
// GitHub uses 2 refs per merge request (refs/pull/ID/head and refs/pull/ID/merge), ensure using */head
exp := regexp.MustCompile("^refs/pull/(.*?)/merge$")
gitRef = exp.ReplaceAllString(gitRef, "refs/pull/${1}/head")
return
}