-
-
Notifications
You must be signed in to change notification settings - Fork 518
Description
I'm using this in a GitHub Actions workflow that edits a few files in separate commits, and then PR's them. I've found that if two separate commits touch the same file, this action squashes all those edits into the first commit that edited the file.
I have a two examples to demonstrate the problem.
Three commits, each editing a log file and each creating a new file
In this example I have three steps (1,2,3) that append "step-N" to a file named log, create an empty file step-N, and make a commit for that step. When this is PR'd, it ends up with:
- step-1 commit: create the
step-1file, andstep-1,step-2, andstep-3, in the log file. - step-2 commit: only create the step-2 file
- step-3 commit: only create the step-3 file
I would instead expect step-1 commit to only include the step-1 line in the log, and step-2 and step-3 log lines to appear in their respective commits.
on:
workflow_dispatch:
jobs:
make-pr:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
env:
GIT_COMMITTER_NAME: example
GIT_COMMITTER_EMAIL: example@example.com
GIT_AUTHOR_NAME: example
GIT_AUTHOR_EMAIL: example@example.com
steps:
- uses: actions/checkout@v4
- run: |
echo "step-1" >> log
touch step-1
git add log step-1
git commit -m "step-1"
- run: |
echo "step-2" >> log
touch step-2
git add log step-2
git commit -m "step-2"
- run: |
echo "step-3" >> log
touch step-3
git add log step-3
git commit -m "step-3"
- uses: peter-evans/create-pull-request@v7
with:
branch: example-patches
delete-branch: true
sign-commits: true
title: step 1, 2, and 3
body: |
hello worldThree commits, each only editing a log file
In this example I have three steps (1,2,3) that append "step-N" to a file named log and make a commit for that step. When this is PR'd, it ends up with:
- step-1 commit: create the
logfile with the log lines from all three steps:step-1,step-2, andstep-3. - step-2 commit: an empty commit
- step-3 commit: an empty commit
I would instead expect step-1 commit to only include the step-1 line in the log, and step-2 and step-3 log lines to appear in their respective commits.
on:
workflow_dispatch:
jobs:
make-pr:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
env:
GIT_COMMITTER_NAME: example
GIT_COMMITTER_EMAIL: example@example.com
GIT_AUTHOR_NAME: example
GIT_AUTHOR_EMAIL: example@example.com
steps:
- uses: actions/checkout@v4
- run: |
echo "step-1" >> log
git add log
git commit -m "step-1"
- run: |
echo "step-2" >> log
git add log
git commit -m "step-2"
- run: |
echo "step-3" >> log
git add log
git commit -m "step-3"
- uses: peter-evans/create-pull-request@v7
with:
branch: example-patches
delete-branch: true
sign-commits: true
title: step 1, 2, and 3
body: |
hello world--
Overall, I would expect each commit to be submitted in the pull request as originally committed, instead of having the changes squash.