How to create a comment to a Gitea PR from drone?

Hello, I’m using Gitea as my version control system and Drone as CI for .Net Core projects. Is there an equivalent plugin like the Github Comment for interacting with Gitea or another way to create a comment to the original PR?

Correction for anyone who is searching.
Gitea treats PRs as issues, so instead of issue index the PR index can be used instead.
https://try.gitea.io/api/swagger#/issue/issueCreateComment

Question on Gitea repository: Issue 12733

I am not aware of an existing plugin for this purpose, however, anyone can create their own custom plugin for Drone. Plugins are just Docker images that execute a simple script or program as the image entrypoint.

You can learn more about creating plugins here:
https://docs.drone.io/plugins/overview/

Also note that plugins are not required. You could also write a simple shell command that uses the Gitea API to post your comment:

- name: comment
  image: curlimages/curl
  commands:
  - curl -X POST -d '{ .... }' https://try.gitea.io/api/repos/...
2 Likes

Ah! Thanks for the quick response. I just looked and I think that the Gitea API does not support comments on PRs only issues.

Correction for anyone who is searching. Gitea treats PRs as issues, so instead of issue index the PR index can be used instead.
https://try.gitea.io/api/swagger#/issue/issueCreateComment

@bradrydzewski Ok I created this plugin that interacts with gitea pr Gitea Comment but I can’t figure out how to cat a file inside settings

The default alpine image behavior would be to run the cat command before the curl command. This is the github repo for the plugin TsakiDev/gitea-comment

A part of my pipeline:

- name: read
image: tsakidev/giteacomment
volumes:
  - name: cache
    path: /report
settings:
  gitea_token:
    from_secret: gitea_bot_token
  gitea_base_url: https://gitea.example.com
  comment: $$(cat /report/output.txt)

The yaml is unmarshaled into a Go structure and the comment attribute is unmarshaled into a string literal. It is not a bash string and is not passed through a bash interpreter, which means it will not execute a bash command and interpolate the results.

If you want to read from a file, you should build that logic into the plugin directly:

settings:
  gitea_token:
    from_secret: gitea_bot_token
  gitea_base_url: https://gitea.example.com
+ comment_from_file: /report/output.txt