Skip to content

Formatting the text in the body #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AshNaz87 opened this issue Mar 15, 2022 · 8 comments · Fixed by #252
Closed

Formatting the text in the body #247

AshNaz87 opened this issue Mar 15, 2022 · 8 comments · Fixed by #252
Labels
question A question on how to use this action

Comments

@AshNaz87
Copy link

Hey folks! Awesome project you have here!

Just have a question regarding the body property when creating a comment.

Is it possible to format it? I.e. make it bold or apply some colour to the text?

This may be in the documentation, but I have not come across it.

Many thanks!

@josh-
Copy link
Contributor

josh- commented Mar 27, 2022

You can use Markdown formatting in the body:

github.rest.issues.createComment({
  issue_number: context.issue.number,
  owner: context.repo.owner,
  repo: context.repo.repo,
  body: "**Bold text here**"
})

Note that if you have a multi-line comment that the indentation must be correct, otherwise your formatted text will be placed
inside an intended code block. Example of correct indentation is:

github.rest.issues.createComment({
  issue_number: context.issue.number,
  owner: context.repo.owner,
  repo: context.repo.repo,
  body: `# Images

    # Title 
    ![](https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png)`
})

@AshNaz87
Copy link
Author

Cheers @josh-

I'll give this a spin. This really ought to be in the documentation

@AshNaz87
Copy link
Author

Works like a charm! Cheers :)

@josh-
Copy link
Contributor

josh- commented Mar 27, 2022

You're welcome! Just opened #252 adding an example to the docs 👍

@joshmgross joshmgross added the question A question on how to use this action label Mar 29, 2022
@kirillgroshkov
Copy link

Note that if you have a multi-line comment that the indentation must be correct, otherwise your formatted text will be placed
inside an intended code block.

Indeed, my issue was a wrong indentation 👍

@amol-patel
Copy link

@josh- We denote code or a command within a sentence using single backticks. Could you please explain how to escape backticks when they're part of the text body?

@joshmgross
Copy link
Member

@amol-patel you should be able to use a \ to escape any backticks:

To escape a backtick in a template literal, put a backslash (\) before the backtick.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

@amol-patel
Copy link

Thank you so much @joshmgross

eskultety added a commit to eskultety/hermeto that referenced this issue Dec 9, 2024
This workflow is a direct consequence of the asynchronous release
schedule of pydantic and pydantic core and the fact that pydantic is
always pinned to a particular pydantic-core version. Dependabot doesn't
see these transitive relations and so can't properly update the
versions in this case (it always assumes the latest for every
dependency). This will naturally lead to broken CI making these version
updates impossible to merge.

Since our project directly only cares about pydantic and not
pydantic-core, we can ignore pydantic-core updates (future patch) and
run a dedicated workflow on every dependabot pull request that would
check whether changes to our requirements files are needed. If changes
are needed, the GitHub actions bot will comment on the pull request
that a change to these files are needed and provide a patch to the
reviewer to apply and update the pull request.

The workflow is only executed when changes to the requirements files
are proposed (realistically only by dependabot). Note that it's not
possible to specify the source branch as the workflow trigger, only the
target branch, and so that could not have been used as a better filter
for dependabot-proposed pull requests specifically. It is run using a
Python Alpine docker image, saves the git diff produced by pip-compile
to the default github actions environment followed by a github script
action that will pop the diff out of the environment and use it to
comment on the pull request.

References:
- https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#multiline-strings
- https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/using-conditions-to-control-job-execution
- https://github.com/actions/github-script?tab=readme-ov-file#comment-on-an-issue
- actions/github-script#247 (comment)
- actions/github-script#220 (comment)

Signed-off-by: Erik Skultety <eskultet@redhat.com>
eskultety added a commit to eskultety/hermeto that referenced this issue Jan 3, 2025
This workflow is a direct consequence of the asynchronous release
schedule of pydantic and pydantic core and the fact that pydantic is
always pinned to a particular pydantic-core version. Dependabot doesn't
see these transitive relations and so can't properly update the
versions in this case (it always assumes the latest for every
dependency). This will naturally lead to broken CI making these version
updates impossible to merge.

Since our project directly only cares about pydantic and not
pydantic-core, we can ignore pydantic-core updates (future patch) and
run a dedicated workflow on every dependabot pull request that would
check whether any additional changes (i.e. transitive dependency
version locks) to our requirements files are needed. If so, then the
GitHub actions bot will comment on the pull request that a change to
these files is needed and will provide a patch to the reviewer to apply
and update the pull request.

The workflow is only executed when changes to the requirements files
are proposed (realistically only by dependabot). Note that it's not
possible to specify the source branch as the workflow trigger, only the
target branch, and so that could not have been used as a better filter
for dependabot-proposed pull requests specifically. It is run using a
Python Alpine docker image, saves the git diff produced by pip-compile
to the default github actions environment followed by a github script
action that will pop the diff out of the environment and use it to
comment on the pull request.

References:
- https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#multiline-strings
- https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/using-conditions-to-control-job-execution
- https://github.com/actions/github-script?tab=readme-ov-file#comment-on-an-issue
- actions/github-script#247 (comment)
- actions/github-script#220 (comment)

Signed-off-by: Erik Skultety <eskultet@redhat.com>
github-merge-queue bot pushed a commit to hermetoproject/hermeto that referenced this issue Jan 6, 2025
This workflow is a direct consequence of the asynchronous release
schedule of pydantic and pydantic core and the fact that pydantic is
always pinned to a particular pydantic-core version. Dependabot doesn't
see these transitive relations and so can't properly update the
versions in this case (it always assumes the latest for every
dependency). This will naturally lead to broken CI making these version
updates impossible to merge.

Since our project directly only cares about pydantic and not
pydantic-core, we can ignore pydantic-core updates (future patch) and
run a dedicated workflow on every dependabot pull request that would
check whether any additional changes (i.e. transitive dependency
version locks) to our requirements files are needed. If so, then the
GitHub actions bot will comment on the pull request that a change to
these files is needed and will provide a patch to the reviewer to apply
and update the pull request.

The workflow is only executed when changes to the requirements files
are proposed (realistically only by dependabot). Note that it's not
possible to specify the source branch as the workflow trigger, only the
target branch, and so that could not have been used as a better filter
for dependabot-proposed pull requests specifically. It is run using a
Python Alpine docker image, saves the git diff produced by pip-compile
to the default github actions environment followed by a github script
action that will pop the diff out of the environment and use it to
comment on the pull request.

References:
- https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#multiline-strings
- https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/using-conditions-to-control-job-execution
- https://github.com/actions/github-script?tab=readme-ov-file#comment-on-an-issue
- actions/github-script#247 (comment)
- actions/github-script#220 (comment)

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question on how to use this action
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants