|
|
@@ -324,13 +324,21 @@ func (g *GithubActions) commitGithubFile(
|
|
|
filepath := ".github/workflows/" + filename
|
|
|
sha := ""
|
|
|
|
|
|
+ branch := g.GitBranch
|
|
|
+
|
|
|
+ if branch == "" {
|
|
|
+ branch = g.defaultBranch
|
|
|
+ }
|
|
|
+
|
|
|
// get contents of a file if it exists
|
|
|
fileData, _, _, _ := client.Repositories.GetContents(
|
|
|
context.TODO(),
|
|
|
g.GitRepoOwner,
|
|
|
g.GitRepoName,
|
|
|
filepath,
|
|
|
- &github.RepositoryContentGetOptions{},
|
|
|
+ &github.RepositoryContentGetOptions{
|
|
|
+ Ref: branch,
|
|
|
+ },
|
|
|
)
|
|
|
|
|
|
if fileData != nil {
|
|
|
@@ -340,7 +348,7 @@ func (g *GithubActions) commitGithubFile(
|
|
|
opts := &github.RepositoryContentFileOptions{
|
|
|
Message: github.String(fmt.Sprintf("Create %s file", filename)),
|
|
|
Content: contents,
|
|
|
- Branch: github.String(g.defaultBranch),
|
|
|
+ Branch: github.String(branch),
|
|
|
SHA: &sha,
|
|
|
Committer: &github.CommitAuthor{
|
|
|
Name: github.String("Porter Bot"),
|