From 0074bd9aaa7b5f8ee8a46358e103eaeb123b6207 Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:20:56 -0500 Subject: [PATCH 01/19] Create pull-request.yml --- .github/workflows/pull-request.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..ee1df5b --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,27 @@ +name: Inspect pull request +on: + - pull_request + +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Check commit message + id: check_message + run: | + commit_message=$(echo '${{ github.event.commits[0].message }}') + if [[ $commit_message == *"feat("* ]] || [[ $commit_message == *"fix("* ]] || [[ $commit_message == *"release("* ]]; then + echo "::set-output name=valid::true" + else + echo "::set-output name=valid::false" + fi + - name: Conditional value for GitHub Action + uses: haya14busa/action-cond@v1.0.0 + id: condval + with: + cond: ${{ steps.check_message.outputs.valid == 'true' }} + if_true: "Commit message is valid" + if_false: "error: Commit message doesn't include 'feat(', 'fix(' or 'release('" + - name: Use conditional value + run: echo "${{ steps.condval.outputs.value }}" + if: failure() \ No newline at end of file From c9f344f265ca917d5b6c8b2bd97e8e1a9c74d0c3 Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:23:29 -0500 Subject: [PATCH 02/19] Update pull-request.yml --- .github/workflows/pull-request.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index ee1df5b..6042ab6 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -6,10 +6,13 @@ jobs: check: runs-on: ubuntu-latest steps: + - name: Retrieve commit messages + id: retrieve_commits + uses: atlwendy/retrieve-commit-messages-from-pr@v3 - name: Check commit message id: check_message run: | - commit_message=$(echo '${{ github.event.commits[0].message }}') + commit_message=$(echo '${{ steps.retrieve_commits.outputs.commit_message }}') if [[ $commit_message == *"feat("* ]] || [[ $commit_message == *"fix("* ]] || [[ $commit_message == *"release("* ]]; then echo "::set-output name=valid::true" else From 443bcdd0e42549d68cecff7e90723e9cfc8a0a6f Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:27:44 -0500 Subject: [PATCH 03/19] Update pull-request.yml --- .github/workflows/pull-request.yml | 39 +++++++++++++----------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 6042ab6..c087794 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,30 +1,25 @@ -name: Inspect pull request +name: Verify Commit Message + on: - - pull_request + pull_request: + types: [opened, synchronize] jobs: - check: + verify-commit-message: runs-on: ubuntu-latest steps: - - name: Retrieve commit messages - id: retrieve_commits - uses: atlwendy/retrieve-commit-messages-from-pr@v3 - - name: Check commit message - id: check_message - run: | - commit_message=$(echo '${{ steps.retrieve_commits.outputs.commit_message }}') - if [[ $commit_message == *"feat("* ]] || [[ $commit_message == *"fix("* ]] || [[ $commit_message == *"release("* ]]; then - echo "::set-output name=valid::true" - else - echo "::set-output name=valid::false" - fi + - name: Checkout code + uses: actions/checkout@v2 - name: Conditional value for GitHub Action uses: haya14busa/action-cond@v1.0.0 - id: condval with: - cond: ${{ steps.check_message.outputs.valid == 'true' }} - if_true: "Commit message is valid" - if_false: "error: Commit message doesn't include 'feat(', 'fix(' or 'release('" - - name: Use conditional value - run: echo "${{ steps.condval.outputs.value }}" - if: failure() \ No newline at end of file + cond: ${{ contains(github.event.head_commit.message, 'feat(') || contains(github.event.head_commit.message, 'fix(') || contains(github.event.head_commit.message, 'release(') }} + if_true: "true" + if_false: "false" + id: check-commit-message + - name: Block merge if commit message is invalid + uses: haya14busa/action-cond@v1.0.0 + with: + cond: ${{ steps.check-commit-message.outputs.value == 'false' }} + if_true: "Invalid commit message. Please include 'feat(', 'fix(', or 'release(' in your commit message." + if_false: "" \ No newline at end of file From b8e77a0a00a969e6ed0eba118ca7f5a3f5291779 Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:28:35 -0500 Subject: [PATCH 04/19] feat(tesst) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d5ff03c..da41a73 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # test -Test sample 7 +Test sample 8 From d0f0ef0a58ba324dbf59c5c265fd50341f4c614c Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:32:09 -0500 Subject: [PATCH 05/19] Update pull-request.yml --- .github/workflows/pull-request.yml | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index c087794..58015a9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,25 +1,19 @@ -name: Verify Commit Message +name: Verificar mensaje del último commit on: pull_request: - types: [opened, synchronize] + types: [opened, synchronize, reopened] jobs: - verify-commit-message: + build: runs-on: ubuntu-latest + steps: - - name: Checkout code + - name: Checkout uses: actions/checkout@v2 - - name: Conditional value for GitHub Action - uses: haya14busa/action-cond@v1.0.0 - with: - cond: ${{ contains(github.event.head_commit.message, 'feat(') || contains(github.event.head_commit.message, 'fix(') || contains(github.event.head_commit.message, 'release(') }} - if_true: "true" - if_false: "false" - id: check-commit-message - - name: Block merge if commit message is invalid - uses: haya14busa/action-cond@v1.0.0 + + - name: Verificar mensaje del último commit + uses: technote-space/conditional-value-for-github-action@v1.0.0 with: - cond: ${{ steps.check-commit-message.outputs.value == 'false' }} - if_true: "Invalid commit message. Please include 'feat(', 'fix(', or 'release(' in your commit message." - if_false: "" \ No newline at end of file + value: '^(feat|fix|release)\(' + error-message: 'El mensaje del último commit no cumple con los requisitos.' From a6227f92b5b128d4a99ed9ac497e0ded295eb37c Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:36:56 -0500 Subject: [PATCH 06/19] Update pull-request.yml --- .github/workflows/pull-request.yml | 32 ++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 58015a9..3ae6672 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,19 +1,31 @@ -name: Verificar mensaje del último commit +name: Check commit message on: pull_request: types: [opened, synchronize, reopened] jobs: - build: + check-commit-message: runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 + + - name: Get last commit message + id: get_commit + run: | + echo "::set-output name=message::$(git log -1 --pretty=%B)" + + - name: Check commit message + id: check_commit + uses: haya14busa/action-cond@v1 + with: + cond: ${{ contains(steps.get_commit.outputs.message, 'feat(') || contains(steps.get_commit.outputs.message, 'fix(') || contains(steps.get_commit.outputs.message, 'release(') }} + if_true: "merge allowed" + if_false: "merge blocked" - - name: Verificar mensaje del último commit - uses: technote-space/conditional-value-for-github-action@v1.0.0 - with: - value: '^(feat|fix|release)\(' - error-message: 'El mensaje del último commit no cumple con los requisitos.' + - name: Block merge if commit message does not contain 'feat(', 'fix(', or 'release(' + run: | + if [ "${{ steps.check_commit.outputs.value }}" == "merge blocked" ]; then + exit 1 + fi From c05e29b58de9ad868f586fc91d7aed04a5b7a8e4 Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:38:08 -0500 Subject: [PATCH 07/19] feat(test) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da41a73..75d7363 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # test -Test sample 8 +Test sample 9 + From c0a463a2cdc17da4ca6f8c1116a66ed1de68ed2f Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:41:57 -0500 Subject: [PATCH 08/19] Update pull-request.yml --- .github/workflows/pull-request.yml | 32 ++++++++++-------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3ae6672..35e6436 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -8,24 +8,14 @@ jobs: check-commit-message: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Get last commit message - id: get_commit - run: | - echo "::set-output name=message::$(git log -1 --pretty=%B)" - - - name: Check commit message - id: check_commit - uses: haya14busa/action-cond@v1 - with: - cond: ${{ contains(steps.get_commit.outputs.message, 'feat(') || contains(steps.get_commit.outputs.message, 'fix(') || contains(steps.get_commit.outputs.message, 'release(') }} - if_true: "merge allowed" - if_false: "merge blocked" - - - name: Block merge if commit message does not contain 'feat(', 'fix(', or 'release(' - run: | - if [ "${{ steps.check_commit.outputs.value }}" == "merge blocked" ]; then - exit 1 - fi + - uses: actions/checkout@v2 + - uses: haya14busa/action-cond@v1 + id: commit-msg + with: + cond: ${{ contains(github.event.head_commit.message, 'feat(') || contains(github.event.head_commit.message, 'fix(') || contains(github.event.head_commit.message, 'release(') }} + if_true: "true" + if_false: "false" + - name: Block merge if commit message is invalid + if: steps.commit-msg.outputs.value == 'false' + run: exit 1 + From 654e08d69b99f9868498e3915982b2264601b94c Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:42:53 -0500 Subject: [PATCH 09/19] feat(test) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75d7363..6479003 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # test -Test sample 9 +Test sample 10 From a649d55045e12b8a310cd6bca050827eadcdef5f Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:48:09 -0500 Subject: [PATCH 10/19] feat( --- .github/workflows/pull-request.yml | 38 +++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 35e6436..78d467c 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -8,14 +8,30 @@ jobs: check-commit-message: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: haya14busa/action-cond@v1 - id: commit-msg - with: - cond: ${{ contains(github.event.head_commit.message, 'feat(') || contains(github.event.head_commit.message, 'fix(') || contains(github.event.head_commit.message, 'release(') }} - if_true: "true" - if_false: "false" - - name: Block merge if commit message is invalid - if: steps.commit-msg.outputs.value == 'false' - run: exit 1 - + - name: Checkout + uses: actions/checkout@v2 + + - name: Get last commit message + id: get_commit + run: | + echo "::set-output name=message::$(git log -1 --pretty=%B)" + - name: Show last commit message + run: | + last_commit_message=$(git log -1 --pretty=%B) + echo "Last commit message:" + echo "$last_commit_message" + shell: bash + + - name: Check commit message + id: check_commit + uses: haya14busa/action-cond@v1 + with: + cond: ${{ contains(steps.get_commit.outputs.message, 'feat(') || contains(steps.get_commit.outputs.message, 'fix(') || contains(steps.get_commit.outputs.message, 'release(') }} + if_true: "merge allowed" + if_false: "merge blocked" + + - name: Block merge if commit message does not contain 'feat(', 'fix(', or 'release(' + run: | + if [ "${{ steps.check_commit.outputs.value }}" == "merge blocked" ]; then + exit 1 + fi From 545745485fd481081713e36c54b7bd9da554b5d0 Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:51:41 -0500 Subject: [PATCH 11/19] feat(t4dt) --- .github/workflows/pull-request.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 78d467c..8082205 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -14,14 +14,16 @@ jobs: - name: Get last commit message id: get_commit run: | + current_commit=$(git rev-parse HEAD) + echo "Current commit of the current branch: $current_commit" echo "::set-output name=message::$(git log -1 --pretty=%B)" - - name: Show last commit message + shell: bash + - name: Get current commit of the current branch run: | - last_commit_message=$(git log -1 --pretty=%B) - echo "Last commit message:" - echo "$last_commit_message" + current_commit=$(git rev-parse HEAD) + echo "Current commit of the current branch: $current_commit" shell: bash - + - name: Check commit message id: check_commit uses: haya14busa/action-cond@v1 From 3943c47456073f3e4af338f2d4d06e615354b8cc Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:57:31 -0500 Subject: [PATCH 12/19] feat --- .github/workflows/pull-request.yml | 35 +++++++----------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 8082205..3d542f7 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,39 +1,20 @@ -name: Check commit message +name: Validate Commit Message on: pull_request: types: [opened, synchronize, reopened] jobs: - check-commit-message: + validate_commit_message: runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout code uses: actions/checkout@v2 - - - name: Get last commit message - id: get_commit - run: | - current_commit=$(git rev-parse HEAD) - echo "Current commit of the current branch: $current_commit" - echo "::set-output name=message::$(git log -1 --pretty=%B)" - shell: bash - - name: Get current commit of the current branch - run: | - current_commit=$(git rev-parse HEAD) - echo "Current commit of the current branch: $current_commit" - shell: bash - - - name: Check commit message - id: check_commit - uses: haya14busa/action-cond@v1 - with: - cond: ${{ contains(steps.get_commit.outputs.message, 'feat(') || contains(steps.get_commit.outputs.message, 'fix(') || contains(steps.get_commit.outputs.message, 'release(') }} - if_true: "merge allowed" - if_false: "merge blocked" - - - name: Block merge if commit message does not contain 'feat(', 'fix(', or 'release(' + - name: Validate commit message + id: validate run: | - if [ "${{ steps.check_commit.outputs.value }}" == "merge blocked" ]; then + commit_message=$(git log -1 --pretty=format:"%s") + if [[ $commit_message != *"feat"* && $commit_message != *"fix"* && $commit_message != *"release"* ]]; then + echo "error: commit message does not contain 'feat', 'fix' or 'release'" exit 1 fi From 1e5799b60d535606bbd8f74c93e14e4ac2b112d1 Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 22:00:16 -0500 Subject: [PATCH 13/19] feat --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3d542f7..fe2a98d 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -13,7 +13,7 @@ jobs: - name: Validate commit message id: validate run: | - commit_message=$(git log -1 --pretty=format:"%s") + commit_message=${{ github.event.commits[0].message }} if [[ $commit_message != *"feat"* && $commit_message != *"fix"* && $commit_message != *"release"* ]]; then echo "error: commit message does not contain 'feat', 'fix' or 'release'" exit 1 From cbf273e3c87829efdf661613e9877c3c6104175b Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 22:22:09 -0500 Subject: [PATCH 14/19] Update pull-request.yml --- .github/workflows/pull-request.yml | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index fe2a98d..1c00364 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,20 +1,17 @@ -name: Validate Commit Message - +name: Your workflow on: pull_request: - types: [opened, synchronize, reopened] + types: [opened, reopened, synchronize, edited] + branches: + - main jobs: - validate_commit_message: + build: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Validate commit message - id: validate - run: | - commit_message=${{ github.event.commits[0].message }} - if [[ $commit_message != *"feat"* && $commit_message != *"fix"* && $commit_message != *"release"* ]]; then - echo "error: commit message does not contain 'feat', 'fix' or 'release'" - exit 1 - fi + - uses: actions/checkout@v2 + - name: Validate Title + uses: FidelusAleksander/gh-action-regex@v0.3.0 + with: + regex_pattern: "^(feat|fix|release|docs|style|refactor|build|ci|perf)\\(.*\\)" + text: ${{ github.event.pull_request.title }} From 4181f7cd22bcfff2cb66cdb8d40da3a5aa031701 Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 22:22:57 -0500 Subject: [PATCH 15/19] feat(test) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6479003..f170bad 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # test -Test sample 10 +Test sample 11 From 1c2e62948c1dc2b4b8f8eb42f7baf131d7b19e09 Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 22:27:51 -0500 Subject: [PATCH 16/19] feat(test): sample message --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 1c00364..2a449c6 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -13,5 +13,5 @@ jobs: - name: Validate Title uses: FidelusAleksander/gh-action-regex@v0.3.0 with: - regex_pattern: "^(feat|fix|release|docs|style|refactor|build|ci|perf)\\(.*\\)" + regex_pattern: "^(feat|fix|docs|style|refactor|perf|test|build|ci)\\(\\w+\\):\\s.+" text: ${{ github.event.pull_request.title }} From 6dd23ea944a19a6486d359fed79ea60cbe902502 Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 22:30:06 -0500 Subject: [PATCH 17/19] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f170bad..99411eb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # test -Test sample 11 +Test sample 12 From 756b7cc71ae6e4df67c813a0c676bbfd337ee652 Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 22:32:22 -0500 Subject: [PATCH 18/19] Update pull-request.yml --- .github/workflows/pull-request.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 2a449c6..7438dc5 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -11,7 +11,24 @@ jobs: steps: - uses: actions/checkout@v2 - name: Validate Title + id: validation uses: FidelusAleksander/gh-action-regex@v0.3.0 with: regex_pattern: "^(feat|fix|docs|style|refactor|perf|test|build|ci)\\(\\w+\\):\\s.+" text: ${{ github.event.pull_request.title }} + + - name: Comment on PR if validation fails + if: steps.validation.outcome == 'failure' + run: | + echo "Title validation failed. Please make sure your pull request title follows the format: 'category(scope): description'" > pr_comment.txt + gh pr comment ${{ github.event.pull_request.number }} --body "$(cat pr_comment.txt)" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Comment on PR if validation passes + if: steps.validation.outcome == 'success' + run: | + echo "Title validation passed." > pr_comment.txt + gh pr comment ${{ github.event.pull_request.number }} --body "$(cat pr_comment.txt)" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 26a46ee087bd37a4efa84e0cc1b4beefa4ceb56e Mon Sep 17 00:00:00 2001 From: Esteban Gonzalez Tamayo <53051438+egonzalezt@users.noreply.github.com> Date: Mon, 16 Oct 2023 22:33:59 -0500 Subject: [PATCH 19/19] Update pull-request.yml --- .github/workflows/pull-request.yml | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 7438dc5..8599c7b 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -11,24 +11,17 @@ jobs: steps: - uses: actions/checkout@v2 - name: Validate Title - id: validation uses: FidelusAleksander/gh-action-regex@v0.3.0 with: regex_pattern: "^(feat|fix|docs|style|refactor|perf|test|build|ci)\\(\\w+\\):\\s.+" text: ${{ github.event.pull_request.title }} - - - name: Comment on PR if validation fails - if: steps.validation.outcome == 'failure' - run: | - echo "Title validation failed. Please make sure your pull request title follows the format: 'category(scope): description'" > pr_comment.txt - gh pr comment ${{ github.event.pull_request.number }} --body "$(cat pr_comment.txt)" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Comment on PR if validation passes - if: steps.validation.outcome == 'success' - run: | - echo "Title validation passed." > pr_comment.txt - gh pr comment ${{ github.event.pull_request.number }} --body "$(cat pr_comment.txt)" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Return message on pull request if validation fails + uses: actions/github-script@v4 + with: + script: | + if (steps.Validate_Title.conclusion === 'failure') { + const pr = context.payload.pull_request; + await github.pulls.createComment(pr.number, { + body: `**Pull request title does not match the required format.** + \ No newline at end of file