diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index d9c9ef6..0000000 --- a/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM ruby:3.2.2-alpine - -RUN apk add --update build-base git - -LABEL "repository"="https://github.com/standardrb/standardrb-action" -LABEL "version"="0.1.0" - -COPY lib /action/lib -COPY README.md LICENSE / - -RUN gem install bundler - -ENTRYPOINT ["/action/lib/entrypoint.sh"] diff --git a/action.yml b/action.yml index f9e03d1..17d459a 100644 --- a/action.yml +++ b/action.yml @@ -1,12 +1,40 @@ - name: 'Standard Ruby' -description: 'A GitHub Action that lints your Ruby code with Standard Ruby' +description: 'A GitHub Action that lints and auto-fixes your Ruby code with Standard Ruby' author: 'Justin Searls ' runs: - using: 'docker' - image: 'Dockerfile' + using: 'composite' + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 'ruby' + bundler-cache: true + + - name: Install dependencies + run: bundle install + + - name: Run Standard Ruby with autofix + run: bundle exec standardrb --fix + id: standardrb + + - name: Commit changes + run: | + git config --global user.name 'standard-ruby-action[bot]' + git config --global user.email 'standard-ruby-action[bot]@users.noreply.github.com' + # Add any files that were changed by Standard Ruby + git diff --name-only --diff-filter=M | xargs git add + git commit -m "Apply Standard Ruby autofixes" || echo "No changes to commit" + git push + + - name: Fail if Standard Ruby failed + if: ${{ steps.standardrb.outcome == 'failure' }} + run: exit 1 + env: - GITHUB_TOKEN: secrets.GITHUB_TOKEN + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} branding: icon: 'code' color: 'gray-dark' diff --git a/lib/entrypoint.sh b/lib/entrypoint.sh deleted file mode 100755 index 9af474d..0000000 --- a/lib/entrypoint.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -set -e - -CMD="standardrb --parallel -f github" - -cd "$GITHUB_WORKSPACE" - -if [ "$USE_BUNDLE_VERSION" = "true" ]; then - echo "[info] using bundled version" - bundle install - CMD="bundle exec $CMD" -else - echo "[info] using current version" - gem install standard -fi - -echo "[info] running standard as '$CMD'" -eval "$CMD"