Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
DEFAULT_BRANCH: ${{ github.ref_name }}
RELEASE_BRANCHES: ${{ github.ref_name }}

- uses: cli/gh-extension-precompile@v2.0.0
with:
Expand Down
22 changes: 22 additions & 0 deletions cmd/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@ func init() {
rootCmd.SetHelpTemplate(generateHelpText())
}

func isGitHubAction() bool {
return os.Getenv("GITHUB_ACTIONS") == "true"
}

func exportGitHubOutput(key, value string) error {
outputPath := os.Getenv("GITHUB_OUTPUT")
if outputPath == "" {
return fmt.Errorf("GITHUB_OUTPUT not set")
}

f, err := os.OpenFile(outputPath, os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
return fmt.Errorf("failed to open GITHUB_OUTPUT file: %w", err)
}
defer func(f *os.File) {
_ = f.Close()
}(f)

_, err = fmt.Fprintf(f, "%s=%s\n", key, value)
return err
}

func (rn *RunSettings) ExecuteDryRun() {
heading := color.New(color.FgCyan, color.Bold).SprintFunc()
fmt.Printf("%s\n\n", heading("The following files would be committed:"))
Expand Down
10 changes: 10 additions & 0 deletions cmd/gh.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/fatih/color"
"net/http"
"os"
"strconv"
)

func ValidateGitRemote() (*RepoSettings, error) {
Expand Down Expand Up @@ -231,6 +232,10 @@ func AssociateCommitWithBranch(branch string, commitSha string) error {
}
}

if isGitHubAction() {
_ = exportGitHubOutput("sha", commitSha)
}

return err
}

Expand Down Expand Up @@ -283,5 +288,10 @@ func CreatePullRequest(baseRef, headRef, title, description string, labels []str
link := color.New(color.FgBlue, color.Bold).Sprintf("🔗 Pull Request URL: %s", prResponse.Url)
fmt.Println(link)

if isGitHubAction() {
_ = exportGitHubOutput("branch", headRef)
_ = exportGitHubOutput("pr-number", strconv.Itoa(prResponse.Number))
}

return nil
}