-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Reset Current Branch to Upstream After Squash Merge | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: 'Branch to reset (leave blank for current branch)' | ||
required: false | ||
default: '' | ||
|
||
jobs: | ||
reset-branch: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Detect Current Branch | ||
if: ${{ inputs.branch == '' }} | ||
run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Use Input Branch | ||
if: ${{ inputs.branch != '' }} | ||
run: echo "branch=${{ inputs.branch }}" >> $GITHUB_ENV | ||
|
||
- name: Add Upstream Remote | ||
run: | | ||
git remote add upstream https://github.com/mlcommons/mlperf-automations.git | ||
git fetch upstream | ||
- name: Reset Branch to Upstream | ||
run: | | ||
git checkout ${{ env.branch }} | ||
git reset --hard upstream/${{ env.branch }} | ||
if: success() | ||
|
||
- name: Force Push to Origin | ||
run: | | ||
git push origin ${{ env.branch }} --force-with-lease | ||
if: success() |