Skip to content

Commit

Permalink
Merge pull request cri-o#6527 from openshift-cherrypick-robot/cherry-…
Browse files Browse the repository at this point in the history
…pick-6516-to-release-1.26

[release-1.26] Inject release-notes branch from GitHub actions
  • Loading branch information
openshift-merge-robot authored Jan 13, 2023
2 parents 17d5fdc + b93180c commit a78722c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ jobs:
~/.cache/go-build
key: go-build-${{ hashFiles('**/go.sum') }}
restore-keys: go-build-
- name: Set current branch
run: |
raw=$(git branch -r --contains ${{ github.ref }})
branch=${raw##*/}
echo "CURRENT_BRANCH=$branch" >> $GITHUB_ENV
- run: make release-notes
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
Expand Down
26 changes: 13 additions & 13 deletions scripts/release-notes/release_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import (
)

const (
branch = "gh-pages"
tokenKey = "GITHUB_TOKEN"
defaultBranch = "main"
branch = "gh-pages"
currentBranchKey = "CURRENT_BRANCH"
tokenKey = "GITHUB_TOKEN"
defaultBranch = "main"
)

var outputPath string
Expand Down Expand Up @@ -72,16 +73,15 @@ func run() error {
}
logrus.Infof("Using HEAD commit %s", head)

targetBranch := defaultBranch
currentBranch, err := repo.CurrentBranch()
if err != nil {
return fmt.Errorf("get current branch: %w", err)
}
logrus.Infof("Found current branch %s", currentBranch)
if git.IsReleaseBranch(currentBranch) && currentBranch != defaultBranch {
targetBranch = currentBranch
currentBranch, currentBranchSet := os.LookupEnv(currentBranchKey)
if !currentBranchSet || currentBranch == "" {
logrus.Infof(
"%s environment variable is not set, using default branch `%s`",
currentBranchKey, defaultBranch,
)
currentBranch = defaultBranch
}
logrus.Infof("Using target branch %s", targetBranch)
logrus.Infof("Using branch: %s", currentBranch)

templateFile, err := os.CreateTemp("", "")
if err != nil {
Expand Down Expand Up @@ -186,7 +186,7 @@ To verify the bill of materials (SBOM) in [SPDX](https://spdx.org) format using
"./build/bin/release-notes",
"--org=cri-o",
"--repo=cri-o",
"--branch="+targetBranch,
"--branch="+currentBranch,
"--repo-path=/tmp/cri-o-repo",
"--required-author=",
"--start-rev="+startTag,
Expand Down

0 comments on commit a78722c

Please sign in to comment.