Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRをgit merge --ff-onlyできるようにする #1

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/ff-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: FF merge
on:
pull_request:
types:
- labeled

jobs:
merge-upstream:
runs-on: ubuntu-20.04
qryxip marked this conversation as resolved.
Show resolved Hide resolved
if: github.event.label.name == 'ff-merge'

steps:
- uses: actions/checkout@v3
with:
ref: main
submodules: true

- name: FF merge
shell: bash
run: |
# https://github.com/robotology/gh-action-nightly-merge/pull/13
git config --global --add safe.directory "$GITHUB_WORKSPACE"

git remote add target "https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY.git"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参考にしたgh-action-nightly-mergeのドキュメントに気になる一言がありました。

https://github.com/robotology/gh-action-nightly-merge#push_token

Useful for pushing on protected branches.

personal tokenを発行すればbranch protectionを貫通できるということ...?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

リポジトリの管理者 or チームにBypass branch protection権限がある人はブランチ保護を無視できたはず…?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最高の権限があったとしても手元からgit push origin mainしたら怒られたと思うので、それが謎でした。このURLではそうではないということですかね...


git fetch origin ${{ github.event.pull_request.head.sha }}
git merge --ff-only ${{ github.event.pull_request.head.sha }}
git push target main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}