Replies: 2 comments
-
Did you try |
Beta Was this translation helpful? Give feedback.
-
@cawa-93 I'd like to leave this comment here for future reference for all the folks who wants to commit then push changes directly to the working branch within Github Actions. Key Takeaways:
Sample workflowname: Push to PR
on:
pull_request:
branches:
- '**'
jobs:
push-to-pr:
name: Push to PR
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }} # Required
- name: Setup Git # Required
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Commit changes
run: |
echo 'test' > test.md
git add .
git commit -m 'chore: new change'
git push |
Beta Was this translation helpful? Give feedback.
-
I would like to create a workflow that would come into each PR and format the code according to the code style. On paper, it looks simple: pull PR, run formatting, push any changes.
My workflow:
And it works great for
push
events. However, I get an error inpull_request
events:I don't understand what caused this error, and how should I initialize the workflow to be able to push changes back to PR
Beta Was this translation helpful? Give feedback.
All reactions