forked from open-sauced/open-sauced
-
Notifications
You must be signed in to change notification settings - Fork 0
/
branch-rename.yml
73 lines (59 loc) · 2.74 KB
/
branch-rename.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Deprecate "master" branch
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
on-push:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
steps:
- name: Deprecation
uses: peter-evans/commit-comment@v1
with:
body: |
Hello @${{ github.event.sender.login }}!
I see that you have pushed some commits to the "master" branch. We are in the process of renaming the "master" branch to "main" in this repository.
:warning: **The "master" branch is deprecated and will be removed from this repository in the future.**
Please migrate your local repository by renaming the "master" branch to "main":
```bash
$ cd my-git-project
$ git checkout master
$ git branch -m main
$ git branch -u origin/main
```
Before merging pull requests, ensure their base branch is set to "main" instead of "master". For more information on how to do this, refer to [this GitHub support article][1].
[1]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/changing-the-base-branch-of-a-pull-request
on-pull-request:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
env:
DEPRECATION_MESSAGE: |
Hello @${{ github.event.sender.login }}!
I see that you have opened a pull request against the "master" branch. We are in the process of renaming the "master" branch to "main" in this repository.
:warning: **The "master" branch is deprecated and will be removed from this repository in the future.**
Please migrate your local repository by renaming the "master" branch to "main":
```bash
$ cd my-git-project
$ git checkout master
$ git branch -m main
$ git branch -u origin/main
```
Please also set the base branch for this pull request to "main" instead of "master". For more information on how to do this, refer to [this GitHub support article][1].
[1]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/changing-the-base-branch-of-a-pull-request
steps:
- name: Deprecation
if: ${{ github.event.pull_request.head.repo.fork == false }}
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.number }}
body: ${{ env.DEPRECATION_MESSAGE }}
- name: Deprecation
if: ${{ github.event.pull_request.head.repo.fork == true }}
run: |
echo "$DEPRECATION_MESSAGE"
echo '::error::Please set the base branch for this pull request to "main" instead of "master".'
exit 1