diff --git a/examples/README.md b/examples/README.md index bb8fb045f..05baffb5c 100644 --- a/examples/README.md +++ b/examples/README.md @@ -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 @@ -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 diff --git a/examples/style.yaml b/examples/style.yaml index 771ef8e68..bee3e482a 100644 --- a/examples/style.yaml +++ b/examples/style.yaml @@ -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 @@ -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