https://github.com/mrthearman/prff
Fast-forward pull requests
https://github.com/mrthearman/prff
fast-forward github-actions merge pull-requests workflow
Last synced: 3 months ago
JSON representation
Fast-forward pull requests
- Host: GitHub
- URL: https://github.com/mrthearman/prff
- Owner: MrThearMan
- License: mit
- Created: 2024-09-18T15:55:18.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-09-24T13:53:11.000Z (9 months ago)
- Last Synced: 2025-03-23T01:01:59.078Z (3 months ago)
- Topics: fast-forward, github-actions, merge, pull-requests, workflow
- Language: Python
- Homepage: https://github.com/marketplace/actions/fast-forward-merge-pull-requests
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fast-forward merge for pull requests
This action adds the ability to fast-forward merge pull requests by
commenting a predefined comment on the pull request.Example:
```yaml
name: Fast-forwardon:
issue_comment:
types:
- created
- editedjobs:
fast-forward:name: Fast-forward
runs-on: ubuntu-latestpermissions:
contents: write # Allows merging the PR.
pull-requests: write # Writing comments on PRs.
issues: write # Also required for posting comments on PRs.# Only run if the comment is one of the defined keywords.
if: >-
${{
github.event.issue.pull_request
&& contains(fromJSON('["/fast-forward", "/ff"]'), github.event.comment.body)
}}steps:
- name: Fast-forward
uses: MrThearMan/prff@v1
```With this, by commenting either `/ff` or `/fast-forward` on the pull request, the action
will run to check if the fast forward merge is possible, and that the commenter has
the requird permissions to make that merge, and then make the merge if those checks pass.If this operation is unsuccessful, a comment will be added to the pull request
with the error. A detailed report is also written to the actions summary.## Note about triggering other workflows
Due to the way GitHub works, pushed created using github actions bots
[do not trigger additional workflows], even if the the workflow would
otherwise be triggered. This applies to this fast-forward action as well.To trigger additional workflows, you can use the `repository_dispatch` event.
Add the following step to your workflow after `uses: MrThearMan/prff@v1`:```yaml
- name: Trigger tests
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "User-Agent: ${{ github.repository }}" \
https://api.github.com/repos/${{ github.repository }}/dispatches \
-d '{"event_type":"fast-forward"}'
```You also need to add the following trigger to the workflow(s) you want to trigger:
```yaml
on:
repository_dispatch:
types:
- fast-forward
```> Note: The `event_type` in the curl command matches the `types` in the workflow trigger.
> Note: If fast-forwarding a pull request fails, the additional workflow will not be triggered,
> since its part of the same job. If desired, you can use the [continue-on-error] option on the
> fast-forward action to run the additional workflow even if the fast-forwarding fails.[do not trigger additional workflows]: https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
[continue-on-error]: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error