diff --git a/.github/workflows/pr_checks.yml b/.github/workflows/pr_checks.yml new file mode 100644 index 0000000..c8797fe --- /dev/null +++ b/.github/workflows/pr_checks.yml @@ -0,0 +1,84 @@ +--- +name: '๐Ÿ” PR Validation' +on: + workflow_call: + inputs: + types: + required: false + type: string + default: | + fix + feat + docs + ci + chore + test + refactor + style + perf + build + revert + requireScope: + required: false + type: boolean + default: false + subjectPattern: + required: false + type: string + default: '^[A-Z].+$' + validateSingleCommit: + required: false + type: boolean + default: false + checkLabels: + required: false + type: boolean + default: true + +jobs: + validate-title: + name: ๐Ÿ“ Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v6.1.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: ${{ inputs.types }} + requireScope: ${{ inputs.requireScope }} + subjectPattern: ${{ inputs.subjectPattern }} + subjectPatternError: | + The subject "{subject}" found in the pull request title "{title}" + didn't match the configured pattern. Please ensure that the subject + starts with an uppercase character. + wip: true + validateSingleCommit: ${{ inputs.validateSingleCommit }} + scopes: | + * + + - name: ๐Ÿท๏ธ Check PR labels + if: ${{ inputs.checkLabels }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [ -z "$(gh api repos/$GITHUB_REPOSITORY/issues/${{ github.event.pull_request.number }}/labels --jq '.[].name')" ]; then + echo "::error::No labels found on this PR. Please add at least one label." + exit 1 + else + echo "PR has labels, validation passed." + fi + + validate-commits: + name: ๐Ÿงพ Validate Commit Messages + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: ๐Ÿงพ Validate Commit Messages + uses: webiny/action-conventional-commits@v1.3.0 + with: + subject_case: false + types: ${{ inputs.types }} +...