Skip to content

Commit

Permalink
test: update github ref used on e2e oncluster tests (knative#1917)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrangelramos authored and matejvasek committed Sep 27, 2023
1 parent 41b56fd commit 7785758
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/oncluster/scenario_github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package oncluster

import (
"path/filepath"
"regexp"
"strings"
"testing"

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 7785758

Please sign in to comment.