Feat no slashes in branches #4
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: Pull Request Checks | |
| on: | |
| pull_request: | |
| branches: | |
| - '**' | |
| jobs: | |
| check-ci-by-failing-here: | |
| runs-on: ubuntu-latest | |
| if: success() || failure() | |
| steps: | |
| - name: cause a fail | |
| run: | | |
| echo "This will fail" | |
| exit 1 # Causes a failure | |
| #continue-on-error: true | |
| branch-name-check: | |
| name: Enforce Branch Name Convention | |
| runs-on: ubuntu-latest | |
| if: success() || failure() | |
| steps: | |
| - name: Validate Branch Name | |
| run: | | |
| #BRANCH_NAME="${GITHUB_HEAD_REF}" | |
| BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}" | |
| echo "Validating branch name: $BRANCH_NAME" | |
| if [[ "$BRANCH_NAME" =~ ^(feat|fix|bugfix|hotfix|build|chore|ci|docs|perf|refactor|revert|style|test)-[a-zA-Z0-9._/-]+$ ]] || [[ "$BRANCH_NAME" == "master" ]]; then | |
| echo "✅ Branch name is valid" | |
| else | |
| echo "❌ Invalid branch name: $BRANCH_NAME" | |
| echo "Branch names must follow one of the allowed prefixes:" | |
| echo " feat-*, fix-*, bugfix-*, hotfix-*, build-*, chore-*, ci-*, docs-*, perf-*, refactor-*, revert-*, style-*, test-*" | |
| exit 1 | |
| fi | |
| #continue-on-error: true | |
| commitlint: | |
| # qqqq repo will need branch protection rules and PR Template | |
| runs-on: ubuntu-latest | |
| if: success() || failure() | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: wagoid/commitlint-github-action@v5 | |
| #continue-on-error: true #we dont want to package etc if bad commits also pre-commit preferred | |
| gitguardian-scan: | |
| runs-on: ubuntu-latest | |
| if: success() || failure() | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: GitGuardian Scan | |
| uses: GitGuardian/gg-shield-action@v1 | |
| env: | |
| GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }} | |
| #continue-on-error: true # we dont want secrets going further and the keys need to be changed if this is triggered | |
| Unit-Tests: | |
| runs-on: ubuntu-latest | |
| if: success() || failure() | |
| steps: | |
| - name: See other project pipeline for Tests | |
| run: echo "qqqq See other project pipeline for Tests this is a placeholder" | |
| #continue-on-error: true | |
| E2E-Tests: | |
| runs-on: ubuntu-latest | |
| if: success() || failure() | |
| steps: | |
| - name: See other project pipeline for Tests | |
| run: echo "qqqq See other project pipeline for Tests this is a placeholder" | |
| #continue-on-error: true | |
| Code-Coverage: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Code Coverage | |
| run: echo "TODO Code Coverage" | |
| #continue-on-error: true | |
| Check-Merge-Conflicts: | |
| runs-on: ubuntu-latest | |
| if: success() || failure() | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for merge conflicts | |
| run: | | |
| git fetch origin main:main | |
| if git merge-tree $(git merge-base main HEAD) main HEAD | grep -i "<<<<<"; then | |
| echo "Merge conflicts detected!" | |
| exit 1 | |
| else | |
| echo "No merge conflicts detected" | |
| fi | |
| #continue-on-error: true | |
| # final-validation: | |
| # name: Final Validation (Fails if any previous job fails) | |
| # runs-on: ubuntu-latest | |
| # needs: | |
| # - branch-name-check | |
| # - commitlint | |
| # - gitguardian-scan | |
| # - Unit-Tests | |
| # - E2E-Tests | |
| # - Code-Coverage | |
| # - Check-Merge-Conflicts | |
| # - check-ci-by-failing-here | |
| # steps: | |
| # - name: Check all previous jobs | |
| # run: | | |
| # failed_jobs="" | |
| # # Check if any job failed and append to the failed_jobs list | |
| # if [[ "${{ needs.branch-name-check.result }}" != "success" ]]; then | |
| # failed_jobs+="branch-name-check, " | |
| # fi | |
| # if [[ "${{ needs.commitlint.result }}" != "success" ]]; then | |
| # failed_jobs+="commitlint, " | |
| # fi | |
| # if [[ "${{ needs.gitguardian-scan.result }}" != "success" ]]; then | |
| # failed_jobs+="gitguardian-scan, " | |
| # fi | |
| # if [[ "${{ needs.Unit-Tests.result }}" != "success" ]]; then | |
| # failed_jobs+="Unit-Tests, " | |
| # fi | |
| # if [[ "${{ needs.E2E-Tests.result }}" != "success" ]]; then | |
| # failed_jobs+="E2E-Tests, " | |
| # fi | |
| # if [[ "${{ needs.Code-Coverage.result }}" != "success" ]]; then | |
| # failed_jobs+="Code-Coverage, " | |
| # fi | |
| # if [[ "${{ needs.Check-Merge-Conflicts.result }}" != "success" ]]; then | |
| # failed_jobs+="Check-Merge-Conflicts, " | |
| # fi | |
| # if [[ "${{ needs.check-ci-by-failing-here.result }}" != "success" ]]; then | |
| # failed_jobs+="check-ci-by-failing-here, " | |
| # fi | |
| # # Remove the last comma if there were failures | |
| # failed_jobs=$(echo $failed_jobs | sed 's/, $//') | |
| # if [[ -n "$failed_jobs" ]]; then | |
| # echo "❌ The following jobs failed: $failed_jobs" | |
| # exit 1 # Fail the final validation if any job failed | |
| # else | |
| # echo "✅ All checks passed!" | |
| # fi | |
| # final-validation: | |
| # name: Final Validation (Fails if any previous job fails) | |
| # runs-on: ubuntu-latest | |
| # needs: [branch-name-check, commitlint, gitguardian-scan, unit-tests, e2e-tests, code-coverage, Check-Merge-Conflicts, check-ci-by-failing-here.result] # Depend on all jobs | |
| # if: ${{ | |
| # needs.branch-name-check.result == 'success' && | |
| # needs.commitlint.result == 'success' && | |
| # needs.gitguardian-scan.result == 'success' && | |
| # needs.unit-tests.result == 'success' && | |
| # needs.e2e-tests.result == 'success' && | |
| # needs.code-coverage.result == 'success' && | |
| # needs.Check-Merge-Conflicts.result == 'success' && | |
| # needs.check-ci-by-failing-here.result == 'success' | |
| # }} | |
| # steps: | |
| # - name: Check all previous jobs | |
| # run: echo "✅ All checks passed!" |