-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (33 loc) · 1.15 KB
/
blank.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
name: Check Feature Branch Origin
on:
pull_request:
types:
- opened
- synchronize
branches:
- 'vnext/*'
jobs:
check-branch-origin:
runs-on: ubuntu-latest
env:
MY_COMMAND: 'git show-branch -a | sed "s/].*//" | grep "\*" | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -n1 | sed "s/^.*\[//"'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: git fetch
run: git fetch
- name: Set Environment Variable
run: echo "TEST=$MY_COMMAND" >> $GITHUB_ENV
- name: Echo Command
run: echo "$TEST"
- name: Get common ancestor commit
id: merge-base
run: echo "COMMIT_HASH=$(git merge-base origin/${{ github.base_ref }} origin/${{ github.head_ref }})" >> $GITHUB_ENV
- name: Verify branch origin
run: |
common_ancestor_commit="$COMMIT_HASH"
first_commit_in_feature_branch=$(git rev-list --max-parents=0 HEAD)
if [ "$common_ancestor_commit" != "$first_commit_in_feature_branch" ]; then
echo "Error: Feature branch was not created from master."
exit 1
fi