Test commit check changes #1
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: verify-all-commits-are-already-in-master | |
on: | |
pull_request: | |
branches: [ "customdc_stable" ] | |
jobs: | |
verify_all_commits_are_already_in_master: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# Fetch all history for accurate comparison | |
fetch-depth: 0 | |
# Check out the PR branch | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
- name: Verify that all commits are already in the master branch | |
run: | | |
git remote add dc https://github.com/datacommonsorg/website.git | |
git fetch dc | |
MASTER_BRANCH="dc/master" | |
# Get the list of commits in the source branch that are not in the master branch | |
MISSING_COMMITS=$(git log --pretty="%H - %s" $MASTER_BRANCH..HEAD --) | |
if [[ -n "$MISSING_COMMITS" ]]; then | |
echo "" | |
echo "ERROR: The following commits are not present in $MASTER_BRANCH:" | |
echo "" | |
echo "$MISSING_COMMITS" | |
echo "" | |
echo "PRs to release branches should only contain commits that are already in master." | |
echo "To fix this PR, reset your branch locally to a commit at or behind https://github.com/datacommonsorg/website/commits/master/ and run `git push --force -u origin`." | |
echo "Note that a release branch PR should be based on master and not the previous version of the release branch, which contains merge commits." | |
exit 1 | |
fi | |
echo "All commits are present in $MASTER_BRANCH" |