Skip to content

Commit 8fcb5c0

Browse files
committed
Create erb_format.yml
This new "ERB Format Check" workflow works as follows: - Executes when a PR is made and gathers any changed `app/views/**/*.erb` files. - Executes `erb-format` against all of the gathered files: - If no files were changed, or if there are no formatting errors, then the GH Action passes. - Else there are formatting errors and the GH Action will fail.
1 parent 084345a commit 8fcb5c0

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/erb_format.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: ERB Format Check
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'app/views/**/*.erb'
7+
8+
jobs:
9+
erb_format:
10+
runs-on: ubuntu-24.04
11+
12+
steps:
13+
# Checkout the repo
14+
- uses: actions/checkout@v2
15+
16+
# Install Ruby and run bundler
17+
- uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: '3.0'
20+
bundler-cache: true
21+
22+
# Gather names of all files within 'app/views/**/*.erb' that have been changed within this PR
23+
# Store those changed files in the `FILES` ENV variable
24+
- name: Get list of changed `app/views/**/*.erb` files
25+
run: |
26+
FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- 'app/views/**/*.erb')
27+
28+
echo "FILES<<EOF" >> $GITHUB_ENV
29+
echo "$FILES" >> $GITHUB_ENV
30+
echo "EOF" >> $GITHUB_ENV
31+
32+
# Check formatting of changed .erb files using erb-format.
33+
# If any file is not properly formatted, this step will fail.
34+
- name: Execute erb-format against all changed `app/views/**/*.erb` files
35+
run: |
36+
if [ -n "$FILES" ]; then
37+
echo "$FILES" | xargs bundle exec erb-format --check
38+
else
39+
echo "No changed files within `app/views/**/*.erb`"
40+
fi

0 commit comments

Comments
 (0)