หลังการติดตั้ง เพียงแสดงความคิดเห็น /rebase
เพื่อกระตุ้นการดำเนินการ:
หากต้องการกำหนดค่าการดำเนินการ เพียงเพิ่มบรรทัดต่อไปนี้ลงในไฟล์เวิร์กโฟลว์ .github/workflows/rebase.yml
ของคุณ:
name : Automatic Rebase
on :
issue_comment :
types : [created]
jobs :
rebase :
name : Rebase
runs-on : ubuntu-latest
if : >-
github.event.issue.pull_request != '' &&
(
contains(github.event.comment.body, '/rebase') ||
contains(github.event.comment.body, '/autosquash')
)
steps :
- name : Checkout the latest code
uses : actions/checkout@v3
with :
token : ${{ secrets.GITHUB_TOKEN }}
fetch-depth : 0 # otherwise, you will fail to push refs to dest repo
- name : Automatic Rebase
uses : cirrus-actions/[email protected]
with :
autosquash : ${{ contains(github.event.comment.body, '/autosquash') || contains(github.event.comment.body, '/rebase-autosquash') }}
env :
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
หมายเหตุ: เพื่อให้แน่ใจว่า GitHub Actions จะถูกรันอีกครั้งโดยอัตโนมัติหลังจากการดำเนินการรีเบสสำเร็จ ให้ใช้ Personal Access Token สำหรับ
actions/checkout@v2
และcirrus-actions/[email protected]
ดูการสนทนาต่อไปนี้สำหรับรายละเอียดเพิ่มเติม
ตัวอย่าง
...
- name : Checkout the latest code
uses : actions/checkout@v3
with :
token : ${{ secrets.PAT_TOKEN }}
fetch-depth : 0 # otherwise, you will fail to push refs to dest repo
- name : Automatic Rebase
uses : cirrus-actions/[email protected]
env :
GITHUB_TOKEN : ${{ secrets.PAT_TOKEN }}
คุณยังสามารถระบุหมายเลข PR ของสาขาที่จะรีบูทได้อีกด้วย หากการดำเนินการที่คุณกำลังดำเนินการอยู่ไม่ได้อ้างอิงถึงคำขอดึงเฉพาะเจาะจงโดยตรง:
- name : Automatic Rebase
uses : cirrus-actions/[email protected]
env :
GITHUB_TOKEN : ${{ secrets.PAT_TOKEN }}
PR_NUMBER : 1245
คุณสามารถใช้ช่อง author_association
ของความคิดเห็นเพื่อจำกัดผู้ที่สามารถเรียกใช้การดำเนินการและข้ามการรีเบสของผู้อื่นได้ เพียงเพิ่มนิพจน์ต่อไปนี้ลงในคำสั่ง if
ในไฟล์เวิร์กโฟลว์ของคุณ: github.event.comment.author_association == 'MEMBER'
ดูเอกสารประกอบสำหรับรายการค่าที่มีอยู่ทั้งหมดของ author_association
GitHub ยังสามารถเลือกที่จะยกเลิกการตรวจสอบที่มีอยู่โดยอัตโนมัติหลังจากการรีบูต ดังนั้นคุณจะต้องอนุมัติอีกครั้งซึ่งจะทริกเกอร์ขั้นตอนการทดสอบ ตั้งค่าใน การตั้งค่า พื้นที่เก็บข้อมูลของคุณ > สาขา > กฎการป้องกันสาขา > ต้องมีการตรวจสอบคำขอดึงก่อนที่จะรวม > ยกเลิกการอนุมัติคำขอดึงเก่าเมื่อมีการส่งคอมมิตใหม่