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)
- Error: Input 'token' not supplied. Unable to continue. HOT 1
- Changes from test folder doesn't added to the PR HOT 10
- Node version - Warning HOT 1
- Permission denied (publickey) HOT 1
- Merge conflict error for different files with different names
- Add branch-label as an output so it can be passed to other actions and easily commited to HOT 2
- PR still created with 0 files (no diffs) HOT 4
- [FEATURE] Add ability to enable auto-merge HOT 1
- Can't figure out how to include commits made during workflow HOT 2
- Action failing to update existing PRs on differently named fork HOT 3
- pr not generated HOT 1
- this works great!
- This works great
- This works great
- When the workflow is triggered with `base` and `branch`, the PR is not created HOT 1
- Syntax error line 17 HOT 2
- remote missing HOT 2
- How to always have open PR from dev to prod HOT 1
- Autosync PR out of date HOT 2
- Automatically delete body-path HOT 1
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.