-
Notifications
You must be signed in to change notification settings - Fork 30
42 lines (37 loc) · 1.14 KB
/
release_protect_branches.yaml
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
name: "🔒 Protect Release Branches"
on:
pull_request:
branches:
- release/*
types:
- opened
- reopened
- synchronize
jobs:
protect-release-branches:
name: "Protect Release Branches"
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
id: checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Check if tag already exists
id: check_tag
run: |
branch_name=${{ github.event.pull_request.base.ref }}
version=${branch_name#"release/"}
git fetch --tags
echo "Checking if tag ${version} already exists..."
if [[ -n $(git tag -l "${version}") ]]; then
echo "Release tag ${version} already exists, thus this branch cannot be changed."
exit 1;
fi
if [[ -n $(git tag -l "${version}-rc.*") ]]; then
echo "Release candidate tag ${version}-rc.* already exists, thus this branch cannot be changed."
exit 1;
fi