mirror of
https://github.com/Jozott00/drone-gitea-message.git
synced 2026-06-16 14:50:23 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 850a48c535 | |||
| 3bd882eccc | |||
| 6dde9c117a | |||
| 260a6f55da |
@@ -1,11 +1,3 @@
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
# GitHub recommends pinning actions to a commit SHA.
|
||||
# To get a newer version, you will need to update the SHA.
|
||||
# You can also reference a tag or branch, but the action may change without warning.
|
||||
|
||||
name: Publish Docker image
|
||||
|
||||
|
||||
@@ -1 +1,69 @@
|
||||
# drone-gitea-messenger
|
||||
# drone-gitea-message
|
||||
[](https://hub.docker.com/r/jozott/drone-gitea-message)
|
||||
|
||||
Drone plugin to send message as comments to Gitea pull requests.
|
||||
All releases are available on [Docker Hub](https://hub.docker.com/r/jozott/drone-gitea-message).
|
||||
|
||||
## Drone YAML Usage
|
||||
|
||||
The plugin support sending text as well as some file's content.
|
||||
By setting the `delete_identifier`, all older comments with the same identifier will be
|
||||
deleted before sending the message.
|
||||
|
||||
### Example of sending a text
|
||||
```yaml
|
||||
steps:
|
||||
- name: send text to pr
|
||||
image: jozott/drone-gitea-message:v0.2.0
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: gitea_token
|
||||
base_url: http://gitea.example.com
|
||||
message_text: "Hello world"
|
||||
```
|
||||
|
||||
### Example of sending content of file
|
||||
```yaml
|
||||
steps:
|
||||
- name: send file content to pr
|
||||
image: jozott/drone-gitea-message:v0.2.0
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: gitea_token
|
||||
base_url: http://gitea.example.com
|
||||
message_file: path/to/hello_world.md
|
||||
```
|
||||
|
||||
### Example with `delete_identifier`
|
||||
If the `delete_identifier` is set, the plugin will delete all existing PR comments
|
||||
that contain the delete identifier. This is handy if sending status updates that make
|
||||
older status updates obsolete.
|
||||
```yaml
|
||||
steps:
|
||||
- name: send test report to pr
|
||||
image: jozott/drone-gitea-message:v0.2.0
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: gitea_token
|
||||
base_url: http://gitea.example.com
|
||||
message_file: build/test/report.md
|
||||
delete_identifier: test-report-delete-id
|
||||
```
|
||||
|
||||
## Build
|
||||
To build the binary execute the following commands
|
||||
```bash
|
||||
export GOOS=linux
|
||||
export GOARCH=amd64
|
||||
export CGO_ENABLED=0
|
||||
export GO111MODULE=on
|
||||
|
||||
go build -v -a -tags netgo -o release/linux/amd64/drone-gitea-message
|
||||
```
|
||||
|
||||
## Run
|
||||
To get all available commands run
|
||||
```
|
||||
./drone-gitea-message --help
|
||||
```
|
||||
|
||||
|
||||
@@ -39,12 +39,6 @@ func main() {
|
||||
Usage: "url of the gitea instance",
|
||||
EnvVar: "PLUGIN_BASE_URL,GITEA_MESSAGE_BASE_URL",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "title",
|
||||
Value: "",
|
||||
Usage: "string for the title shown in the gitea pr comment",
|
||||
EnvVar: "PLUGIN_TITLE,GITEA_MESSAGE_TITLE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "delete-identifier",
|
||||
Value: "",
|
||||
@@ -105,7 +99,6 @@ func run(c *cli.Context) error {
|
||||
MessageText: c.String("message-text"),
|
||||
MessageFile: c.String("message-file"),
|
||||
BaseURl: c.String("base-url"),
|
||||
Title: c.String("title"),
|
||||
DeleteIdentifier: c.String("delete-identifier"),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ type messageClient struct {
|
||||
Owner string
|
||||
Repo string
|
||||
Index int64
|
||||
Title string
|
||||
Message string
|
||||
DeleteIdentifier string
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ type (
|
||||
MessageText string
|
||||
MessageFile string
|
||||
BaseURl string
|
||||
Title string
|
||||
DeleteIdentifier string
|
||||
}
|
||||
Plugin struct {
|
||||
@@ -70,6 +69,10 @@ func (p Plugin) Exec() error {
|
||||
return fmt.Errorf("failed to glob %s. %s", p.Config.MessageFile, err)
|
||||
}
|
||||
|
||||
if len(glob) == 0 {
|
||||
return fmt.Errorf("no file found matching %s", p.Config.MessageFile)
|
||||
}
|
||||
|
||||
content, err = os.ReadFile(glob[0])
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read the file %s. %s", glob[0], err)
|
||||
@@ -97,7 +100,6 @@ func (p Plugin) Exec() error {
|
||||
Owner: p.Repo.Owner,
|
||||
Repo: p.Repo.Name,
|
||||
Index: p.Pr.Index,
|
||||
Title: p.Config.Title,
|
||||
Message: string(content),
|
||||
DeleteIdentifier: p.Config.DeleteIdentifier,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user