Skip to content

Commit a581d2f

Browse files
authored
Merge pull request #14 from fac/adding-working-directory-input
Adding working-directory support
2 parents a936064 + d63feec commit a581d2f

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,20 @@ This action supports [debug logging](https://docs.github.com/en/actions/managing
100100

101101
## Inputs
102102

103+
### working-directory
104+
Sets the working directory before all other steps occur. This is useful for cases where files like `.ruby-version` and `Gemfile` aren't located in the root directory. For example in a monorepo where the Ruby project is located in its own subfolder.
105+
106+
```yaml
107+
name: Push Gem
108+
uses: fac/ruby-gem-push-action@v1
109+
with:
110+
working-directory: './ruby_project/'
111+
```
112+
103113
### gem-glob
104114

105115
File glob to match the gem file to push. The default `pkg/*.gem` picks up gems built using `bundle exec rake build`. You may need to set this if your your gem builds another way.
116+
_Note_: `working-directory` is set before this step, therefore if both inputs are provided, this path will be relative to the `working-directory`.
106117

107118
```yaml
108119
- name: Push Gem

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ inputs:
1818
tag:
1919
description: After pushing a new gem version, git tag with the version string
2020
default: true
21+
working-directory:
22+
description: "The working directory of the ruby project. Useful for cases where files like .ruby-version and Gemfile aren't located in the root directory."
23+
required: false
24+
default: "."
2125
outputs:
2226
pushed-version:
2327
description: "The version of the gem pushed to the repository"
@@ -34,4 +38,5 @@ runs:
3438
args=""
3539
[ '${{ inputs.pre-release }}' == true ] && args="$args -p"
3640
[ '${{ inputs.tag }}' == true ] && args="$args -t"
41+
[ ! -z ${{ inputs.working-directory }} ] && cd ${{ inputs.working-directory }}
3742
gem-push-action.sh -k "${{inputs.key}}" $args ${{inputs.gem-glob}}

parse-gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ require 'optparse'
55
gemspecs = Dir["*.gemspec"]
66

77
if gemspecs.empty?
8-
warn "No gemspec found"
8+
warn "No gemspec found in #{Dir.pwd}"
99
exit 10
1010
end
1111

1212
if gemspecs.count > 1
13-
warn "More than one gemspec found"
13+
warn "More than one gemspec found in #{Dir.pwd}"
1414
exit 10
1515
end
1616

0 commit comments

Comments
 (0)