ci(conventional-commit-check): run checks on being added to queue (#1152)

This commit is contained in:
Sanchith Hegde
2023-05-13 14:49:14 +05:30
committed by GitHub
parent f5bb994b09
commit daf1f2e0af

View File

@ -8,9 +8,13 @@ on:
- reopened
- ready_for_review
merge_group:
types:
- checks_requested
permissions:
# Reference: https://github.com/cli/cli/issues/6274
repository-projects: read
repository-projects: write
pull-requests: write
env:
@ -35,6 +39,7 @@ jobs:
- uses: Swatinem/rust-cache@v2.2.0
with:
key: "pr_title_check"
cache-on-failure: "true"
- name: Install cocogitto
@ -43,13 +48,22 @@ jobs:
- name: Verify PR title follows conventional commit standards
id: pr_title_check
if: ${{ github.event_name == 'pull_request' }}
shell: bash
continue-on-error: true
run: cog verify "${{ github.event.pull_request.title }}"
- name: Verify commit message follows conventional commit standards
id: commit_message_check
if: ${{ github.event_name == 'merge_group' }}
shell: bash
# Fail on error, we don't have context about PR information to update labels
continue-on-error: false
run: cog verify "${{ github.event.merge_group.head_commit.message }}"
# GitHub CLI returns a successful error code even if the PR has the label already attached
- name: Attach 'S-conventions-not-followed' label if PR title check failed
if: ${{ steps.pr_title_check.outcome == 'failure' }}
if: ${{ github.event_name == 'pull_request' && steps.pr_title_check.outcome == 'failure' }}
shell: bash
env:
GH_TOKEN: ${{ github.token }}
@ -60,7 +74,7 @@ jobs:
# GitHub CLI returns a successful error code even if the PR does not have the label attached
- name: Remove 'S-conventions-not-followed' label if PR title check succeeded
if: ${{ steps.pr_title_check.outcome == 'success' }}
if: ${{ github.event_name == 'pull_request' && steps.pr_title_check.outcome == 'success' }}
shell: bash
env:
GH_TOKEN: ${{ github.token }}