Comments (8)
Hi @qdm12
The issue is that pull_request
events checkout a merge commit. If you want to raise a pull request to merge into an existing pull request you need to checkout the head_ref
. See the documentation here:
https://github.com/peter-evans/create-pull-request/blob/master/docs/concepts-guidelines.md#pull-request-events
Also, push
should only run on master
so that you aren't creating two PRs for pull request branches.
name: Misspells
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
misspell:
runs-on: ubuntu-latest
steps:
- name: Checkout on push
if: github.event_name == 'push'
uses: actions/checkout@v2
- name: Checkout on pull_request
if: github.event_name == 'pull_request'
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: sobolevn fixer
uses: sobolevn/misspell-fixer-action@master
- uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Typos fixes'
title: "Typos fixes"
branch: typos
branch-suffix: timestamp
When using branch-suffix: timestamp
, you might end up with a lot of PRs created if your repo has a lot of activity. It can be a bit awkward to use this action well on pull_request
events. Personally, I would avoid if possible and just make the solution simpler by running on push to master
only. That way you can use the fixed-branch strategy easier.
name: Misspells
on:
push:
branches:
- master
jobs:
misspell:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: sobolevn fixer
uses: sobolevn/misspell-fixer-action@master
- uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Typos fixes'
title: "Typos fixes"
branch: typos
from create-pull-request.
If you want to perform operations on PRs (like correcting typos, formatting) I recommend using a slash command instead of raising another PR to merge into the PR branch. See slash-command-dispatch, and in particular, the ChatOps in Pull Requests demo.
from create-pull-request.
Apparently, this will work for both local PRs and PRs from forks. I will update the docs to this snippet instead of the one I mentioned above.
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
from create-pull-request.
Thanks so much for the detailed help!
I'll stick with the PR approach for now (not too much activity yet / not too much spelling mistakes 😆 ), although your other slash command action is quite exciting as well.
Have a great weekend!!
from create-pull-request.
Hi again,
Actually would you know the checkout step so that it would work for PR from forked repositories? In my case it's this log I obtain, using this workflow file - almost the same as yours I think.
Thank you so much 👍
from create-pull-request.
Actually using this format gives the same error as before 😢 (log), workflow was:
name: Misspells
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
misspell:
runs-on: ubuntu-latest
steps:
- name: Checkout on push
if: github.event_name == 'push'
uses: actions/checkout@v2
- name: Checkout on pull_request
if: github.event_name == 'pull_request'
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: reviewdog fixer
uses: reviewdog/action-misspell@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
locale: "US"
- name: sobolevn fixer
uses: sobolevn/misspell-fixer-action@master
- uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Typos fixes'
title: "Typos fixes"
branch: typos
branch-suffix: timestamp
from create-pull-request.
Sorry @qdm12. I didn't think about this long enough before I replied with this comment. I've tried a lot of this in the past and essentially gave up. Basically, what you are trying to do is not possible with PRs from forks (or the workaround is so complicated it's undesirable). The PR branch lives in the fork. Most likely you have no access to the fork. So when you think about it, what is this workflow trying to do? You want to create a pull request in the fork to update the PR branch? The only way you could do that is if you have write access to the fork, or, you create a fork of the fork and raise a PR back to update it.
So one option would be to only run on pull_request
events when the PR is local and not from a fork. This would still check when the fork PRs are merged to master
.
name: Misspells
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
misspell:
+ # Check if the PR is not from a fork
+ if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout on push
if: github.event_name == 'push'
uses: actions/checkout@v2
- name: Checkout on pull_request
if: github.event_name == 'pull_request'
uses: actions/checkout@v2
with:
- ref: ${{ github.event.pull_request.head.sha }}
+ ref: ${{ github.head_ref }}
- name: reviewdog fixer
uses: reviewdog/action-misspell@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
locale: "US"
- name: sobolevn fixer
uses: sobolevn/misspell-fixer-action@master
- uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Typos fixes'
title: "Typos fixes"
branch: typos
branch-suffix: timestamp
As I mentioned previously, if you really want a solution to check/fix both local and fork PRs I suggest to use slash-command-dispatch.
from create-pull-request.
@qdm12 Hope you managed to find a setup that works well for you. Closing this issue for now.
from create-pull-request.
Related Issues (20)
- Creating PR in another repo HOT 2
- Base parameter causes extremely slow checkout of our monorepo HOT 2
- PR creation while checking out from tag HOT 3
- punycode module is deprecated HOT 1
- Action Fails to update existing PRs on Private repos HOT 2
- Using environment variables in `body-path` file HOT 1
- bit
- I'm confused what the `base` option is supposed to do HOT 1
- Don't require a deep fetch for forks HOT 11
- Token generated from GitHub App not working with push-to-fork HOT 4
- Default to "Squash and Merge" HOT 1
- I get error "protected branch hook declined" when I try to create a draft pull request into protected branch HOT 1
- Force update the branch of existing pull request HOT 1
- Empty PRs being created, is this expected? HOT 4
- Error creating new PR HOT 2
- `title-path` and `commit-message-path` inputs HOT 1
- `base` also does a checkout to that branch HOT 1
- Update multiple repositories HOT 2
- ignore untracked HOT 2
- NO PR created and branch changes to new branch and updates from main HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from create-pull-request.