From 958060d61f396b4af52a56f9ba02aef5fa86ec00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Jos=C3=A9=20de=20Oliveira=20J=C3=BAnior?= Date: Wed, 20 Jul 2022 00:18:14 -0300 Subject: [PATCH 01/11] feat: outputs the error messages --- src/validatePrTitle.js | 49 ++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/src/validatePrTitle.js b/src/validatePrTitle.js index f3369134b..5907baf7c 100644 --- a/src/validatePrTitle.js +++ b/src/validatePrTitle.js @@ -1,3 +1,4 @@ +const core = require('@actions/core'); const conventionalCommitsConfig = require('conventional-changelog-conventionalcommits'); const conventionalCommitTypes = require('conventional-commit-types'); const parser = require('conventional-commits-parser').sync; @@ -5,6 +6,8 @@ const formatMessage = require('./formatMessage'); const defaultTypes = Object.keys(conventionalCommitTypes.types); +let errorMessage + module.exports = async function validatePrTitle( prTitle, { @@ -52,30 +55,26 @@ module.exports = async function validatePrTitle( } if (!result.type) { - throw new Error( - `No release type found in pull request title "${prTitle}". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/\n\n${printAvailableTypes()}` - ); + errorMessage = `No release type found in pull request title "${prTitle}". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/\n\n${printAvailableTypes()}`; + throw new Error(errorMessage); } if (!result.subject) { - throw new Error(`No subject found in pull request title "${prTitle}".`); + errorMessage = `No subject found in pull request title "${prTitle}".`; + throw new Error(errorMessage); } - if (!types.includes(result.type)) { - throw new Error( - `Unknown release type "${ - result.type - }" found in pull request title "${prTitle}". \n\n${printAvailableTypes()}` - ); + if (!types.includes(result.type)) { + errorMessage = `Unknown release type "${result.type}" found in pull request title "${prTitle}". \n\n${printAvailableTypes()}`; + throw new Error(errorMessage); } if (requireScope && !result.scope) { - let msg = `No scope found in pull request title "${prTitle}".`; + errorMessage = `No scope found in pull request title "${prTitle}".`; if (scopes) { - msg += ` Use one of the available scopes: ${scopes.join(', ')}.`; + errorMessage += ` Use one of the available scopes: ${scopes.join(', ')}.`; } - - throw new Error(msg); + throw new Error(errorMessage); } const givenScopes = result.scope @@ -84,26 +83,16 @@ module.exports = async function validatePrTitle( const unknownScopes = givenScopes ? givenScopes.filter(isUnknownScope) : []; if (scopes && unknownScopes.length > 0) { - throw new Error( - `Unknown ${ - unknownScopes.length > 1 ? 'scopes' : 'scope' - } "${unknownScopes.join( - ',' - )}" found in pull request title "${prTitle}". Use one of the available scopes: ${scopes.join( - ', ' - )}.` - ); + errorMessage = `Unknown ${unknownScopes.length > 1 ? 'scopes' : 'scope'} "${unknownScopes.join(',')}" found in pull request title "${prTitle}". Use one of the available scopes: ${scopes.join(', ')}.`; + throw new Error(errorMessage); } const disallowedScopes = givenScopes ? givenScopes.filter(isDisallowedScope) : []; if (disallowScopes && disallowedScopes.length > 0) { - throw new Error( - `Disallowed ${ - disallowedScopes.length === 1 ? 'scope was' : 'scopes were' - } found: ${disallowScopes.join(', ')}` - ); + errorMessage = `Disallowed ${disallowedScopes.length === 1 ? 'scope was' : 'scopes were'} found: ${disallowScopes.join(', ')}`; + throw new Error(errorMessage); } function throwSubjectPatternError(message) { @@ -114,6 +103,8 @@ module.exports = async function validatePrTitle( }); } + errorMessage = message; + throw new Error(message); } @@ -133,4 +124,6 @@ module.exports = async function validatePrTitle( ); } } + + core.setOutput("error_message", errorMessage) }; From 4f185571630b0671bbb63e458ec74c8b657efc78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Jos=C3=A9=20de=20Oliveira=20J=C3=BAnior?= Date: Wed, 20 Jul 2022 00:30:56 -0300 Subject: [PATCH 02/11] style: run eslint src --fix --- src/validatePrTitle.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/validatePrTitle.js b/src/validatePrTitle.js index 5907baf7c..256dc3f79 100644 --- a/src/validatePrTitle.js +++ b/src/validatePrTitle.js @@ -6,7 +6,7 @@ const formatMessage = require('./formatMessage'); const defaultTypes = Object.keys(conventionalCommitTypes.types); -let errorMessage +let errorMessage; module.exports = async function validatePrTitle( prTitle, @@ -64,8 +64,10 @@ module.exports = async function validatePrTitle( throw new Error(errorMessage); } - if (!types.includes(result.type)) { - errorMessage = `Unknown release type "${result.type}" found in pull request title "${prTitle}". \n\n${printAvailableTypes()}`; + if (!types.includes(result.type)) { + errorMessage = `Unknown release type "${ + result.type + }" found in pull request title "${prTitle}". \n\n${printAvailableTypes()}`; throw new Error(errorMessage); } @@ -83,7 +85,13 @@ module.exports = async function validatePrTitle( const unknownScopes = givenScopes ? givenScopes.filter(isUnknownScope) : []; if (scopes && unknownScopes.length > 0) { - errorMessage = `Unknown ${unknownScopes.length > 1 ? 'scopes' : 'scope'} "${unknownScopes.join(',')}" found in pull request title "${prTitle}". Use one of the available scopes: ${scopes.join(', ')}.`; + errorMessage = `Unknown ${ + unknownScopes.length > 1 ? 'scopes' : 'scope' + } "${unknownScopes.join( + ',' + )}" found in pull request title "${prTitle}". Use one of the available scopes: ${scopes.join( + ', ' + )}.`; throw new Error(errorMessage); } @@ -91,7 +99,9 @@ module.exports = async function validatePrTitle( ? givenScopes.filter(isDisallowedScope) : []; if (disallowScopes && disallowedScopes.length > 0) { - errorMessage = `Disallowed ${disallowedScopes.length === 1 ? 'scope was' : 'scopes were'} found: ${disallowScopes.join(', ')}`; + errorMessage = `Disallowed ${ + disallowedScopes.length === 1 ? 'scope was' : 'scopes were' + } found: ${disallowScopes.join(', ')}`; throw new Error(errorMessage); } @@ -125,5 +135,5 @@ module.exports = async function validatePrTitle( } } - core.setOutput("error_message", errorMessage) + core.setOutput('error_message', errorMessage); }; From a0adbcd590aebb2315cb08c0f654cefc35a1a975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Jos=C3=A9=20de=20Oliveira=20J=C3=BAnior?= Date: Wed, 20 Jul 2022 18:57:24 -0300 Subject: [PATCH 03/11] fix: setOutput never getting called --- src/validatePrTitle.js | 60 +++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/validatePrTitle.js b/src/validatePrTitle.js index 256dc3f79..4897d27b8 100644 --- a/src/validatePrTitle.js +++ b/src/validatePrTitle.js @@ -55,28 +55,29 @@ module.exports = async function validatePrTitle( } if (!result.type) { - errorMessage = `No release type found in pull request title "${prTitle}". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/\n\n${printAvailableTypes()}`; - throw new Error(errorMessage); + raiseError( + `No release type found in pull request title "${prTitle}". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/\n\n${printAvailableTypes()}` + ); } if (!result.subject) { - errorMessage = `No subject found in pull request title "${prTitle}".`; - throw new Error(errorMessage); + raiseError(`No subject found in pull request title "${prTitle}".`); } if (!types.includes(result.type)) { - errorMessage = `Unknown release type "${ - result.type - }" found in pull request title "${prTitle}". \n\n${printAvailableTypes()}`; - throw new Error(errorMessage); + raiseError( + `Unknown release type "${ + result.type + }" found in pull request title "${prTitle}". \n\n${printAvailableTypes()}` + ); } if (requireScope && !result.scope) { - errorMessage = `No scope found in pull request title "${prTitle}".`; + let message = `No scope found in pull request title "${prTitle}".`; if (scopes) { - errorMessage += ` Use one of the available scopes: ${scopes.join(', ')}.`; + message += ` Use one of the available scopes: ${scopes.join(', ')}.`; } - throw new Error(errorMessage); + raiseError(message); } const givenScopes = result.scope @@ -85,24 +86,26 @@ module.exports = async function validatePrTitle( const unknownScopes = givenScopes ? givenScopes.filter(isUnknownScope) : []; if (scopes && unknownScopes.length > 0) { - errorMessage = `Unknown ${ - unknownScopes.length > 1 ? 'scopes' : 'scope' - } "${unknownScopes.join( - ',' - )}" found in pull request title "${prTitle}". Use one of the available scopes: ${scopes.join( - ', ' - )}.`; - throw new Error(errorMessage); + raiseError( + `Unknown ${ + unknownScopes.length > 1 ? 'scopes' : 'scope' + } "${unknownScopes.join( + ',' + )}" found in pull request title "${prTitle}". Use one of the available scopes: ${scopes.join( + ', ' + )}.` + ); } const disallowedScopes = givenScopes ? givenScopes.filter(isDisallowedScope) : []; if (disallowScopes && disallowedScopes.length > 0) { - errorMessage = `Disallowed ${ - disallowedScopes.length === 1 ? 'scope was' : 'scopes were' - } found: ${disallowScopes.join(', ')}`; - throw new Error(errorMessage); + raiseError( + `Disallowed ${ + disallowedScopes.length === 1 ? 'scope was' : 'scopes were' + } found: ${disallowScopes.join(', ')}` + ); } function throwSubjectPatternError(message) { @@ -112,10 +115,7 @@ module.exports = async function validatePrTitle( title: prTitle }); } - - errorMessage = message; - - throw new Error(message); + raiseError(message); } if (subjectPattern) { @@ -136,4 +136,10 @@ module.exports = async function validatePrTitle( } core.setOutput('error_message', errorMessage); + + function raiseError(message) { + core.setOutput('errorMessage', message); + + throw new Error(message); + } }; From 278a1ec859fc4cabac33c494830f06501f7d8a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Jos=C3=A9=20de=20Oliveira=20J=C3=BAnior?= Date: Wed, 20 Jul 2022 18:58:22 -0300 Subject: [PATCH 04/11] refactor: remove unused variable --- src/validatePrTitle.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/validatePrTitle.js b/src/validatePrTitle.js index 4897d27b8..e1d18c2d8 100644 --- a/src/validatePrTitle.js +++ b/src/validatePrTitle.js @@ -6,8 +6,6 @@ const formatMessage = require('./formatMessage'); const defaultTypes = Object.keys(conventionalCommitTypes.types); -let errorMessage; - module.exports = async function validatePrTitle( prTitle, { From 7c2e077d1f2642b2622362a536651d2268a769b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Jos=C3=A9=20de=20Oliveira=20J=C3=BAnior?= Date: Wed, 20 Jul 2022 20:12:04 -0300 Subject: [PATCH 05/11] refactor: remove unused call --- src/validatePrTitle.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/validatePrTitle.js b/src/validatePrTitle.js index e1d18c2d8..a380eb0a2 100644 --- a/src/validatePrTitle.js +++ b/src/validatePrTitle.js @@ -133,8 +133,6 @@ module.exports = async function validatePrTitle( } } - core.setOutput('error_message', errorMessage); - function raiseError(message) { core.setOutput('errorMessage', message); From 8f50de914fbfaa87ef7f3f0df497e452edea1507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Jos=C3=A9=20de=20Oliveira=20J=C3=BAnior?= Date: Wed, 20 Jul 2022 20:12:38 -0300 Subject: [PATCH 06/11] refactor: change output name to official docs style --- src/validatePrTitle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validatePrTitle.js b/src/validatePrTitle.js index a380eb0a2..328a501e3 100644 --- a/src/validatePrTitle.js +++ b/src/validatePrTitle.js @@ -134,7 +134,7 @@ module.exports = async function validatePrTitle( } function raiseError(message) { - core.setOutput('errorMessage', message); + core.setOutput('ERROR_MESSAGE', message); throw new Error(message); } From 1800f478d9482fbe158ca137cc7f32456f37eaa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Jos=C3=A9=20de=20Oliveira=20J=C3=BAnior?= Date: Wed, 20 Jul 2022 20:32:32 -0300 Subject: [PATCH 07/11] feat: create new workflow to test output messages --- .../lint-pr-title-preview-outputErrorMessage | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/lint-pr-title-preview-outputErrorMessage diff --git a/.github/workflows/lint-pr-title-preview-outputErrorMessage b/.github/workflows/lint-pr-title-preview-outputErrorMessage new file mode 100644 index 000000000..3bfd46f11 --- /dev/null +++ b/.github/workflows/lint-pr-title-preview-outputErrorMessage @@ -0,0 +1,28 @@ +name: "Lint PR title preview (current branch, outputErrorMessage)" +on: + pull_request: + types: + - opened + - edited + - synchronize + +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + - run: yarn install + - run: yarn build + - uses: ./ + id: lint_pr_title + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Comment on PR + if: always() + uses: marocchino/sticky-pull-request-comment@v2 + with: + message: ${{ steps.lint_pr_title.outputs.ERROR_MESSAGE }} \ No newline at end of file From eae7697392de93f787e5378c64d86cdcbe308b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Jos=C3=A9=20de=20Oliveira=20J=C3=BAnior?= Date: Thu, 21 Jul 2022 11:36:32 -0300 Subject: [PATCH 08/11] docs: add information about outputs on readme.md --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README.md b/README.md index e2ab8e72a..6bc93f1be 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,53 @@ There are two events that can be used as triggers for this action, each with dif 1. [`pull_request_target`](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target): This allows the action to be used in a fork-based workflow, where e.g. you want to accept pull requests in a public repository. In this case, the configuration from the main branch of your repository will be used for the check. This means that you need to have this configuration in the main branch for the action to run at all (e.g. it won't run within a PR that adds the action initially). Also if you change the configuration in a PR, the changes will not be reflected for the current PR – only subsequent ones after the changes are in the main branch. 2. [`pull_request`](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request): This configuration uses the latest configuration that is available in the current branch. It will only work if the branch is based in the repository itself. If this configuration is used and a pull request from a fork is opened, you'll encounter an error as the GitHub token environment parameter is not available. This option is viable if all contributors have write access to the repository. +## Outputs + +- `ERROR_MESSAGE`: The error message created by this action case the validation fails + +This actions outputs the error message raised in the validation, so you can use it in other steps or jobs. + +- First, assign an ID to the action-semantic-pull-request step. +- On the next step, add an "if: always()" to force it to run. This is necessary because otherwise the whole workflow would just stop when action-semantic-pull-request throws the error. +- Get the output by using an expression pointing to the action-semantic-pull-request ID. +- Do what you want with it. + +In the example below, we use the [sticky-pull-request-comment](https://github.com/marketplace/actions/sticky-pull-request-comment) action to create a comment in the PR with the error message outputed by this action. + +```yml +name: "Lint PR" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v4 + # Assign an ID to the step. + id: lint_pr_title + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Comment on PR + # Since this action throws an error that naturaly stops the workflow execution, + # add an "if: always()" to force it to run. + # In this case, to comment on the PR. + if: always() + uses: marocchino/sticky-pull-request-comment@v2 + with: + # Get the output using an expression, pointing to the ID you assigned. + message: ${{ steps.lint_pr_title.outputs.ERROR_MESSAGE }} +``` + +You can read more about outputs in the [GitHub Documentation](https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs). + ## Legacy configuration When using "Squash and merge" on a PR with only one commit, GitHub will suggest using that commit message instead of the PR title for the merge commit and it's easy to commit this by mistake. To help out in this situation this action supports two configuration options. However, [GitHub has introduced an option to streamline this behaviour](https://github.blog/changelog/2022-05-11-default-to-pr-titles-for-squash-merge-commit-messages/), so using that instead should be preferred. From 44f0be2a2f992155f78b2f88f4c05e280d165f07 Mon Sep 17 00:00:00 2001 From: Jan Amann Date: Mon, 25 Jul 2022 13:27:19 +0200 Subject: [PATCH 09/11] Lowercase error_message --- .github/workflows/lint-pr-title-preview-outputErrorMessage | 2 +- README.md | 4 ++-- src/validatePrTitle.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint-pr-title-preview-outputErrorMessage b/.github/workflows/lint-pr-title-preview-outputErrorMessage index 3bfd46f11..1c93e6ec5 100644 --- a/.github/workflows/lint-pr-title-preview-outputErrorMessage +++ b/.github/workflows/lint-pr-title-preview-outputErrorMessage @@ -25,4 +25,4 @@ jobs: if: always() uses: marocchino/sticky-pull-request-comment@v2 with: - message: ${{ steps.lint_pr_title.outputs.ERROR_MESSAGE }} \ No newline at end of file + message: ${{ steps.lint_pr_title.outputs.error_message }} \ No newline at end of file diff --git a/README.md b/README.md index 6bc93f1be..6cb2bd1a3 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ There are two events that can be used as triggers for this action, each with dif ## Outputs -- `ERROR_MESSAGE`: The error message created by this action case the validation fails +- `error_message`: The error message created by this action case the validation fails This actions outputs the error message raised in the validation, so you can use it in other steps or jobs. @@ -155,7 +155,7 @@ jobs: uses: marocchino/sticky-pull-request-comment@v2 with: # Get the output using an expression, pointing to the ID you assigned. - message: ${{ steps.lint_pr_title.outputs.ERROR_MESSAGE }} + message: ${{ steps.lint_pr_title.outputs.error_message }} ``` You can read more about outputs in the [GitHub Documentation](https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs). diff --git a/src/validatePrTitle.js b/src/validatePrTitle.js index 328a501e3..14630b3c5 100644 --- a/src/validatePrTitle.js +++ b/src/validatePrTitle.js @@ -134,7 +134,7 @@ module.exports = async function validatePrTitle( } function raiseError(message) { - core.setOutput('ERROR_MESSAGE', message); + core.setOutput('error_message', message); throw new Error(message); } From cb5e1aeaea5c2c433ef5fe17ae40e104ee900aac Mon Sep 17 00:00:00 2001 From: Jan Amann Date: Mon, 25 Jul 2022 13:37:59 +0200 Subject: [PATCH 10/11] Shorten docs --- README.md | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 6cb2bd1a3..4433d8994 100644 --- a/README.md +++ b/README.md @@ -115,16 +115,12 @@ There are two events that can be used as triggers for this action, each with dif ## Outputs -- `error_message`: The error message created by this action case the validation fails +In case the validation fails, this action will populate the `error_message` ouput. -This actions outputs the error message raised in the validation, so you can use it in other steps or jobs. +[An output can be used in other steps](https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs), for example to comment the error message onto the pull request. -- First, assign an ID to the action-semantic-pull-request step. -- On the next step, add an "if: always()" to force it to run. This is necessary because otherwise the whole workflow would just stop when action-semantic-pull-request throws the error. -- Get the output by using an expression pointing to the action-semantic-pull-request ID. -- Do what you want with it. - -In the example below, we use the [sticky-pull-request-comment](https://github.com/marketplace/actions/sticky-pull-request-comment) action to create a comment in the PR with the error message outputed by this action. +
+Example ```yml name: "Lint PR" @@ -142,23 +138,19 @@ jobs: runs-on: ubuntu-latest steps: - uses: amannn/action-semantic-pull-request@v4 - # Assign an ID to the step. id: lint_pr_title env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Comment on PR - # Since this action throws an error that naturaly stops the workflow execution, - # add an "if: always()" to force it to run. - # In this case, to comment on the PR. + - uses: marocchino/sticky-pull-request-comment@v2 + # When the previous steps fails, the workflow would stop. By adding this + # condition you can continue the execution with the populated error message. if: always() - uses: marocchino/sticky-pull-request-comment@v2 with: - # Get the output using an expression, pointing to the ID you assigned. message: ${{ steps.lint_pr_title.outputs.error_message }} ``` -You can read more about outputs in the [GitHub Documentation](https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs). +
## Legacy configuration From 70b57258e3bbad517e096cb4ceb0ec2d655593a0 Mon Sep 17 00:00:00 2001 From: Jan Amann Date: Mon, 26 Sep 2022 10:51:20 +0200 Subject: [PATCH 11/11] Improved example --- .../lint-pr-title-preview-outputErrorMessage | 24 +++++++++++++++---- README.md | 19 ++++++++++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint-pr-title-preview-outputErrorMessage b/.github/workflows/lint-pr-title-preview-outputErrorMessage index 1c93e6ec5..2a96a0bf4 100644 --- a/.github/workflows/lint-pr-title-preview-outputErrorMessage +++ b/.github/workflows/lint-pr-title-preview-outputErrorMessage @@ -20,9 +20,25 @@ jobs: id: lint_pr_title env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Comment on PR + - uses: marocchino/sticky-pull-request-comment@v2 + # When the previous steps fails, the workflow would stop. By adding this + # condition you can continue the execution with the populated error message. if: always() - uses: marocchino/sticky-pull-request-comment@v2 with: - message: ${{ steps.lint_pr_title.outputs.error_message }} \ No newline at end of file + header: pr-title-lint-error + message: | + Hey there and thank you for opening this pull request! 👋🏼 + + We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted. + + Details: + + ``` + ${{ steps.lint_pr_title.outputs.error_message }} + ``` + # Delete a previous comment when the issue has been resolved + - if: ${{ steps.lint_pr_title.outputs.error_message == null }} + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: pr-title-lint-error + delete: true \ No newline at end of file diff --git a/README.md b/README.md index 4433d8994..21fb237c7 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,24 @@ jobs: # condition you can continue the execution with the populated error message. if: always() with: - message: ${{ steps.lint_pr_title.outputs.error_message }} + header: pr-title-lint-error + message: | + Hey there and thank you for opening this pull request! 👋🏼 + + We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted. + + Details: + + ``` + ${{ steps.lint_pr_title.outputs.error_message }} + ``` + + # Delete a previous comment when the issue has been resolved + - if: ${{ steps.lint_pr_title.outputs.error_message == null }} + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: pr-title-lint-error + delete: true ```