Skip to content

Commit

Permalink
Merge pull request #186 from 5ouma/feat-env-config
Browse files Browse the repository at this point in the history
Get the config file path from the environment variable
  • Loading branch information
Songmu authored Oct 27, 2024
2 parents 3c58530 + 67f08da commit 1877c63
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
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

0 comments on commit 1877c63

Please sign in to comment.