From 77f14557d874c854bf47048bd37c81554997fbb1 Mon Sep 17 00:00:00 2001 From: Nan Xiao Date: Sat, 8 Jul 2023 19:13:30 -0400 Subject: [PATCH] Update GitHub Actions workflows --- .github/workflows/pkgdown.yaml | 2 ++ .github/workflows/style.yaml | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 087f0b0..ed7650c 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -19,6 +19,8 @@ jobs: group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml index 771ef8e..bee3e48 100644 --- a/.github/workflows/style.yaml +++ b/.github/workflows/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