-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (38 loc) · 1.65 KB
/
ruby-lint.yml
File metadata and controls
45 lines (38 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Ruby Lint
on:
workflow_call:
secrets:
BUNDLE_RUBYGEMS__PKG__GITHUB__COM:
description: "The GitHub token to use for private gem sources"
required: true
jobs:
lint:
runs-on: ubuntu-latest
env:
BUNDLE_RUBYGEMS__PKG__GITHUB__COM: ${{ secrets.BUNDLE_RUBYGEMS__PKG__GITHUB__COM }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Get base and head
id: base-head
run: |
git fetch origin ${{ github.base_ref }} ${{ github.event.pull_request.head.ref }}
echo "FORK_POINT=$(git show-branch --merge-base "origin/${{ github.base_ref }}" "origin/${{ github.event.pull_request.head.ref }}")" >> "$GITHUB_OUTPUT"
echo "LATEST_COMMIT_IN_PR=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
- name: Get changed Ruby files
env:
FORK_POINT: ${{ steps.base-head.outputs.FORK_POINT }}
LATEST_COMMIT_IN_PR: ${{ steps.base-head.outputs.LATEST_COMMIT_IN_PR }}
RUBY_PATTERN: (\.r[bu]|\.gemspec|\.podspec|\.jbuilder|\.rake|Gemfile|Rakefile|Capfile|Guardfile|Podfile|Thorfile|Vagrantfile)$
id: changed-files
run: |
echo "CHANGED_RUBY_FILES=$(git diff --diff-filter=ACMR --name-only $FORK_POINT $LATEST_COMMIT_IN_PR | grep -E $RUBY_PATTERN | tr '\n' ' ')" >> "$GITHUB_OUTPUT"
- name: Rubocop on changed files
env:
CHANGED_RUBY_FILES: ${{ steps.changed-files.outputs.CHANGED_RUBY_FILES }}
run: |
if [ -n "$CHANGED_RUBY_FILES" ]; then
bundle exec rubocop $CHANGED_RUBY_FILES
fi