Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the config file path from the environment variable #186

Merged
merged 2 commits into from
Oct 27, 2024
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ If you are using GitHub Enterprise, use `GH_ENTERPRISE_TOKEN` instead of `GITHUB
GH_ENTERPRISE_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

## Inputs for GitHub Actions

### config (Optional)
A path to the tagpr configuration file.
If not specified, it will be ".tagpr" in the repository root.

## Outputs for GitHub Actions

The tagpr produces output to be used in conjunction with subsequent GitHub Actions jobs.
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ inputs:
description: "A version to install tagpr"
required: false
default: "v1.4.3"
config:
description: "A path to the tagpr configuration file"
required: false
outputs:
tag:
description: "The semver tag, which is output only when the tagpr has tagged"
Expand All @@ -25,6 +28,8 @@ runs:
curl -sfL https://raw.githubusercontent.com/Songmu/tagpr/main/install.sh | sh -s -- -b "$TEMP_PATH" "${{ inputs.version }}" 2>&1
tagpr
shell: bash
env:
TAGPR_CONFIG_FILE: ${{ inputs.config }}
branding:
icon: 'git-pull-request'
color: 'blue'
9 changes: 7 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const (
`
defaultMajorLabels = "major"
defaultMinorLabels = "minor"
envConfigFile = "TAGPR_CONFIG_FILE"
envReleaseBranch = "TAGPR_RELEASE_BRANCH"
envVersionFile = "TAGPR_VERSION_FILE"
envVPrefix = "TAGPR_VPREFIX"
Expand Down Expand Up @@ -89,9 +90,13 @@ type config struct {
}

func newConfig(gitPath string) (*config, error) {
var conf = defaultConfigFile
if cf := os.Getenv(envConfigFile); cf != "" {
conf = cf
}
cfg := &config{
conf: defaultConfigFile,
gitconfig: &gitconfig.Config{GitPath: gitPath, File: defaultConfigFile},
conf: conf,
gitconfig: &gitconfig.Config{GitPath: gitPath, File: conf},
}
err := cfg.Reload()
return cfg, err
Expand Down
Loading