MCDRpost 3.3.1 #4
This file contains hidden or 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: Pull Request Checks | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| validate-pr: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check if PR is from allowed branches | |
| run: | | |
| BRANCH_NAME="${{ github.head_ref }}" | |
| if [[ $BRANCH_NAME == dev/* ]] || [[ $BRANCH_NAME == hotfix/* ]]; then | |
| echo "✓ Pull request is from an allowed branch: $BRANCH_NAME" | |
| echo "ALLOWED_BRANCH_CHECK=true" >> $GITHUB_ENV | |
| echo "SOURCE_BRANCH=$BRANCH_NAME" >> $GITHUB_ENV | |
| else | |
| echo "Error: Pull requests to master branch can only come from dev/* or hotfix/* branches" | |
| echo "Current branch: $BRANCH_NAME" | |
| echo "ALLOWED_BRANCH_CHECK=false" >> $GITHUB_ENV | |
| echo "SOURCE_BRANCH=$BRANCH_NAME" >> $GITHUB_ENV | |
| exit 1 | |
| fi | |
| - name: Additional checks for feature branches | |
| run: | | |
| BRANCH_NAME="${{ github.head_ref }}" | |
| if [[ $BRANCH_NAME == feature/* ]]; then | |
| echo "Error: feature/* branches cannot be merged directly to master" | |
| echo "Please merge feature branches to dev/* branches first" | |
| echo "FEATURE_BRANCH_CHECK=false" >> $GITHUB_ENV | |
| exit 1 | |
| else | |
| echo "FEATURE_BRANCH_CHECK=skipped" >> $GITHUB_ENV | |
| fi | |
| - name: Check commit signing | |
| run: | | |
| # This job can be expanded to check other PR requirements | |
| echo "PR source validation completed" | |
| echo "VALIDATION_COMPLETED=true" >> $GITHUB_ENV | |
| - name: Create Job Summary | |
| run: | | |
| echo "## Pull Request Validation Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Check | Result |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Allowed Branch Check | ${{ env.ALLOWED_BRANCH_CHECK }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Feature Branch Check | ${{ env.FEATURE_BRANCH_CHECK }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Validation Completed | ${{ env.VALIDATION_COMPLETED }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Source branch: ${{ env.SOURCE_BRANCH }}" >> $GITHUB_STEP_SUMMARY |