Skip to content

Commit 4f847c7

Browse files
committed
change style action to PR instead of push
1 parent 5d5b9c4 commit 4f847c7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

.github/workflows/style.yaml

+9-3
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,22 @@ jobs:
6464
run: styler::style_pkg()
6565
shell: Rscript {0}
6666

67-
- name: Commit and push changes
67+
- name: Commit and create PR
6868
run: |
6969
if FILES_TO_COMMIT=($(git diff-index --name-only ${{ github.sha }} \
7070
| egrep --ignore-case '\.(R|[qR]md|Rmarkdown|Rnw|Rprofile)$'))
7171
then
7272
git config --local user.name "$GITHUB_ACTOR"
7373
git config --local user.email "[email protected]"
74+
75+
BRANCH_NAME="gha-style-${{ github.run_id }}"
76+
git checkout -b "$BRANCH_NAME"
7477
git commit ${FILES_TO_COMMIT[*]} -m "Style code (GHA)"
75-
git pull --ff-only
76-
git push origin
78+
git push origin "$BRANCH_NAME"
79+
80+
gh pr create --base master --head "$BRANCH_NAME" --title "Apply styler formatting" --body "This PR applies automated styling fixes."
7781
else
7882
echo "No changes to commit."
7983
fi
84+
env:
85+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)