diff --git a/README.md b/README.md index a5ef377..3711168 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ permissions: - `ruby-version` - If your project has a `.ruby-version` file, this Action will use that version of Ruby. If not, this will be forwarded to the [ruby/setup-ruby](https://github.com/ruby/setup-ruby) action, so it takes the same values. - `autofix` - If set to `false`, the action will not attempt to auto-fix any errors. Defaults to `true`. +- `workdir` - If set the action will descend to this directory before running `bundle exec standardrb …`. Defaults to `.`. Example with options set: @@ -62,6 +63,7 @@ Example with options set: with: ruby-version: '3.3' autofix: false + workdir: my/app/subdirectory ``` ## Screenshots diff --git a/action.yml b/action.yml index e6781e8..df2fb32 100644 --- a/action.yml +++ b/action.yml @@ -11,6 +11,9 @@ inputs: description: 'Whether autofixes should be committed back to the branch' required: false default: 'true' + workdir: + description: "The working directory from which to run this action's commands. Default '.'" + default: '.' runs: using: composite @@ -22,6 +25,7 @@ runs: - name: Check for .ruby-version file id: use_ruby_version_or_default shell: bash + working-directory: ${{ inputs.workdir }} run: | if [ -f .ruby-version ]; then echo "Using Ruby version from .ruby-version file" @@ -36,16 +40,19 @@ runs: with: ruby-version: ${{ env.ruby-version || inputs.ruby-version }} bundler-cache: true + working-directory: ${{ inputs.workdir }} - name: Run Standard Ruby with autofix id: standardrb shell: bash + working-directory: ${{ inputs.workdir }} run: bundle exec standardrb ${{ inputs.autofix == 'true' && '--fix' || '' }} --format github --format "Standard::Formatter" continue-on-error: true - name: Check for modified files id: check_changes shell: bash + working-directory: ${{ inputs.workdir }} run: | if [ -n "$(git diff --name-only --diff-filter=M)" ]; then echo "standardrb_autofixes_found=true" >> $GITHUB_ENV