From 082781511c615ffb5fe0205c1b69ed2d2f79497c Mon Sep 17 00:00:00 2001 From: LinZhihao-723 Date: Sat, 30 Nov 2024 19:56:51 -0500 Subject: [PATCH 1/4] Add conventional commit PR title check --- .github/PULL_REQUEST_TEMPLATE.md | 9 +++++++-- .github/workflows/pr-title-checks.yaml | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pr-title-checks.yaml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 9672f6d..d965596 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,10 @@ -# References - + # Description diff --git a/.github/workflows/pr-title-checks.yaml b/.github/workflows/pr-title-checks.yaml new file mode 100644 index 0000000..6cfb301 --- /dev/null +++ b/.github/workflows/pr-title-checks.yaml @@ -0,0 +1,23 @@ +name: "pr-title-checks" + +on: + pull_request_target: + types: ["edited", "opened", "reopened"] + branches: ["main"] + +concurrency: + group: "${{github.workflow}}-${{github.ref}}" + + # Cancel in-progress jobs for efficiency + cancel-in-progress: true + +jobs: + conventional-commits: + permissions: + # For amannn/action-semantic-pull-request + pull-requests: "read" + runs-on: "ubuntu-latest" + steps: + - uses: "amannn/action-semantic-pull-request@v5" + env: + GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}" From 6a16efcaaf5b89c144105f94318ce55106d28723 Mon Sep 17 00:00:00 2001 From: LinZhihao-723 Date: Sat, 30 Nov 2024 23:37:16 -0500 Subject: [PATCH 2/4] Add comment --- .github/workflows/pr-title-checks.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pr-title-checks.yaml b/.github/workflows/pr-title-checks.yaml index 6cfb301..e34a7d7 100644 --- a/.github/workflows/pr-title-checks.yaml +++ b/.github/workflows/pr-title-checks.yaml @@ -2,6 +2,11 @@ name: "pr-title-checks" on: pull_request_target: + # NOTE: The `pull_request_target` event means GITHUB_TOKEN can access secrets and is granted + # read/write repository access by default. So we need to ensure: + # - This workflow doesn't inadvertently check out, build, or execute untrusted code from the + # pull request triggered by this event. + # - Each job has `permissions` set to only those necessary. types: ["edited", "opened", "reopened"] branches: ["main"] From 642280202a3b566e6d1ad75ded1f9c1c3115306c Mon Sep 17 00:00:00 2001 From: Lin Zhihao <59785146+LinZhihao-723@users.noreply.github.com> Date: Sun, 1 Dec 2024 00:46:03 -0500 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com> --- .github/workflows/pr-title-checks.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-title-checks.yaml b/.github/workflows/pr-title-checks.yaml index e34a7d7..91e241b 100644 --- a/.github/workflows/pr-title-checks.yaml +++ b/.github/workflows/pr-title-checks.yaml @@ -2,13 +2,14 @@ name: "pr-title-checks" on: pull_request_target: - # NOTE: The `pull_request_target` event means GITHUB_TOKEN can access secrets and is granted - # read/write repository access by default. So we need to ensure: + # NOTE: Workflows triggered by this event give the workflow access to secrets and grant the + # `GITHUB_TOKEN` read/write repository access by default. So we need to ensure: # - This workflow doesn't inadvertently check out, build, or execute untrusted code from the # pull request triggered by this event. # - Each job has `permissions` set to only those necessary. types: ["edited", "opened", "reopened"] branches: ["main"] +permissions: {} concurrency: group: "${{github.workflow}}-${{github.ref}}" From 39d9236e7441cf357875b033ac85cda457861f4f Mon Sep 17 00:00:00 2001 From: LinZhihao-723 Date: Sun, 1 Dec 2024 01:01:48 -0500 Subject: [PATCH 4/4] Add extra space --- .github/PULL_REQUEST_TEMPLATE.md | 1 + .github/workflows/pr-title-checks.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index d965596..6b6cd51 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,6 +2,7 @@ Set the PR title to a meaningful commit message that: - follows the Conventional Commits specification (https://www.conventionalcommits.org). - is in imperative form. + Example: fix: Don't add implicit wildcards ('*') at the beginning and the end of a query (fixes #390). --> diff --git a/.github/workflows/pr-title-checks.yaml b/.github/workflows/pr-title-checks.yaml index 91e241b..0aed19c 100644 --- a/.github/workflows/pr-title-checks.yaml +++ b/.github/workflows/pr-title-checks.yaml @@ -9,6 +9,7 @@ on: # - Each job has `permissions` set to only those necessary. types: ["edited", "opened", "reopened"] branches: ["main"] + permissions: {} concurrency: