Feature/based on vnext/1.43 #13
Workflow file for this run
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
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 |