Skip to content

Commit

Permalink
Merge pull request #693 from dpprdan/fix/commit_all_styled_files
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi authored Apr 4, 2023
2 parents 7434f9e + cb06414 commit 4723ad2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
23 changes: 13 additions & 10 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,7 @@ changes to the same branch.
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
paths: ["**.[rR]", "**.[qrR]md", "**.[rR]markdown", "**.[rR]nw"]
pull_request:
paths: ["**.[rR]", "**.[qrR]md", "**.[rR]markdown", "**.[rR]nw"]
paths: ["**.[rR]", "**.[qrR]md", "**.[rR]markdown", "**.[rR]nw", "**.[rR]profile"]
name: Style
Expand Down Expand Up @@ -675,17 +673,22 @@ jobs:
${{ runner.os }}-
- name: Style
run: styler::style_pkg(filetype = c(".R", ".Rmd", ".Rmarkdown", ".Rnw"))
run: styler::style_pkg()
shell: Rscript {0}
- name: Commit and push changes
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add R/\*
git commit -m "Style code" || echo "No changes to commit"
git pull --ff-only
git push origin
if FILES_TO_COMMIT=($(git diff-index --name-only ${{ github.sha }} \
| egrep --ignore-case '\.(R|[qR]md|Rmarkdown|Rnw|Rprofile)$'))
then
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git commit ${FILES_TO_COMMIT[*]} -m "Style code (GHA)"
git pull --ff-only
git push origin
else
echo "No changes to commit."
fi
```

## Build bookdown site
Expand Down
21 changes: 13 additions & 8 deletions examples/style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
paths: ["**.[rR]", "**.[qrR]md", "**.[rR]markdown", "**.[rR]nw"]
paths: ["**.[rR]", "**.[qrR]md", "**.[rR]markdown", "**.[rR]nw", "**.[rR]profile"]

name: Style

Expand Down Expand Up @@ -55,14 +55,19 @@ jobs:
${{ runner.os }}-
- name: Style
run: styler::style_pkg(filetype = c(".R", ".Rmd", ".Rmarkdown", ".Rnw"))
run: styler::style_pkg()
shell: Rscript {0}

- name: Commit and push changes
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add R/\*
git commit -m "Style code" || echo "No changes to commit"
git pull --ff-only
git push origin
if FILES_TO_COMMIT=($(git diff-index --name-only ${{ github.sha }} \
| egrep --ignore-case '\.(R|[qR]md|Rmarkdown|Rnw|Rprofile)$'))
then
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git commit ${FILES_TO_COMMIT[*]} -m "Style code (GHA)"
git pull --ff-only
git push origin
else
echo "No changes to commit."
fi

0 comments on commit 4723ad2

Please sign in to comment.