forked from melpa/melpa
-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (40 loc) · 1.1 KB
/
reset-on-merge.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Reset on merge
on:
pull_request:
types:
- closed
jobs:
reset:
if: |
github.event.pull_request.merged == true &&
github.base_ref == 'akirak' &&
github.head_ref == 'rebase-akirak' &&
github.event.pull_request.head.repo.id == github.event.pull_request.base.repo.id
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.base_ref }}
- name: Tag the last head revision
id: backup
run: |
tag="${{ github.base_ref }}-backup-$(date +'%Y%m%d%H%M%S')"
git tag "$tag" "$(git rev-parse HEAD~1)"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Push the tag
uses: ad-m/github-push-action@master
with:
tags: true
branch: ${{ steps.backup.outputs.tag }}
- name: Reset
run: |
git fetch origin "$rev"
git reset --hard "$rev"
env:
rev: ${{ github.head_ref }}
- name: Push the resetted branch
uses: ad-m/github-push-action@master
with:
branch: ${{ github.base_ref }}
force: true