docs: 添加 MCDR 插件文档 #43
Workflow file for this run
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: Feature Branch Protection | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| - dev | |
| jobs: | |
| check-feature-branch: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check feature branch destination | |
| run: | | |
| SOURCE_BRANCH="${{ github.head_ref }}" | |
| TARGET_BRANCH="${{ github.base_ref }}" | |
| # If source is a feature branch | |
| if [[ $SOURCE_BRANCH == feature/* ]]; then | |
| # It can only be merged to dev/* branches | |
| if [[ $TARGET_BRANCH == dev/* ]]; then | |
| echo "✓ Feature branch $SOURCE_BRANCH can be merged to $TARGET_BRANCH" | |
| echo "FEATURE_BRANCH_CHECK=true" >> $GITHUB_ENV | |
| else | |
| echo "Error: Feature branches can only be merged to dev/* branches" | |
| echo "Source branch: $SOURCE_BRANCH" | |
| echo "Target branch: $TARGET_BRANCH" | |
| echo "FEATURE_BRANCH_CHECK=false" >> $GITHUB_ENV | |
| exit 1 | |
| fi | |
| else | |
| echo "FEATURE_BRANCH_CHECK=skipped" >> $GITHUB_ENV | |
| fi | |
| # If source is a fix branch | |
| if [[ $SOURCE_BRANCH == fix/* ]]; then | |
| # It can only be merged to dev/* branches | |
| if [[ $TARGET_BRANCH == dev/* ]]; then | |
| echo "✓ Fix branch $SOURCE_BRANCH can be merged to $TARGET_BRANCH" | |
| echo "FIX_BRANCH_CHECK=true" >> $GITHUB_ENV | |
| else | |
| echo "Error: Fix branches can only be merged to dev/* branches" | |
| echo "Source branch: $SOURCE_BRANCH" | |
| echo "Target branch: $TARGET_BRANCH" | |
| echo "FIX_BRANCH_CHECK=false" >> $GITHUB_ENV | |
| exit 1 | |
| fi | |
| else | |
| echo "FIX_BRANCH_CHECK=skipped" >> $GITHUB_ENV | |
| fi | |
| # If merging to master, only allow dev/* or hotfix/* branches | |
| if [[ $TARGET_BRANCH == master ]]; then | |
| if [[ $SOURCE_BRANCH == dev/* ]] || [[ $SOURCE_BRANCH == hotfix/* ]]; then | |
| echo "✓ $SOURCE_BRANCH can be merged to $TARGET_BRANCH" | |
| echo "MASTER_BRANCH_CHECK=true" >> $GITHUB_ENV | |
| else | |
| echo "Error: Only dev/* or hotfix/* branches can be merged to master" | |
| echo "Source branch: $SOURCE_BRANCH" | |
| echo "Target branch: $TARGET_BRANCH" | |
| echo "MASTER_BRANCH_CHECK=false" >> $GITHUB_ENV | |
| exit 1 | |
| fi | |
| else | |
| echo "MASTER_BRANCH_CHECK=skipped" >> $GITHUB_ENV | |
| fi | |
| - name: Create Job Summary | |
| run: | | |
| echo "## Branch Protection Check Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Check | Result |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Feature Branch Check | ${{ env.FEATURE_BRANCH_CHECK }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Fix Branch Check | ${{ env.FIX_BRANCH_CHECK }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Master Branch Check | ${{ env.MASTER_BRANCH_CHECK }} |" >> $GITHUB_STEP_SUMMARY |