mirror of
https://github.com/thegeeklab/wp-gitea-release.git
synced 2024-11-21 03:40:40 +00:00
docs: cleanup docs and parameters
This commit is contained in:
parent
95511ca41e
commit
9980b6624d
2
.github/settings.yml
vendored
2
.github/settings.yml
vendored
@ -1,6 +1,6 @@
|
||||
repository:
|
||||
name: wp-gitea-release
|
||||
description: Woodpecker CI plugin to add comments to GitHub Issues and Pull Requests
|
||||
description: Woodpecker CI plugin to publish files and artifacts to Gitea releases
|
||||
homepage: https://woodpecker-plugins.geekdocs.de/plugins/wp-gitea-release
|
||||
topics: woodpecker-ci, woodpecker, woodpecker-plugin
|
||||
|
||||
|
@ -53,7 +53,7 @@ steps:
|
||||
target: DOCKER_USER
|
||||
environment:
|
||||
PUSHRM_FILE: README.md
|
||||
PUSHRM_SHORT: Woodpecker CI plugin to add comments to GitHub Issues and Pull Requests
|
||||
PUSHRM_SHORT: Woodpecker CI plugin to publish files and artifacts to Gitea releases
|
||||
PUSHRM_TARGET: ${CI_REPO}
|
||||
when:
|
||||
- event: [push, manual]
|
||||
|
@ -1,6 +1,6 @@
|
||||
# wp-gitea-release
|
||||
|
||||
Woodpecker CI plugin to add comments to GitHub Issues and Pull Requests
|
||||
Woodpecker CI plugin to publish files and artifacts to Gitea releases
|
||||
|
||||
[![Build Status](https://ci.thegeeklab.de/api/badges/thegeeklab/wp-gitea-release/status.svg)](https://ci.thegeeklab.de/repos/thegeeklab/wp-gitea-release)
|
||||
[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/wp-gitea-release)
|
||||
@ -10,7 +10,7 @@ Woodpecker CI plugin to add comments to GitHub Issues and Pull Requests
|
||||
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/wp-gitea-release)
|
||||
[![License: Apache-2.0](https://img.shields.io/github/license/thegeeklab/wp-gitea-release)](https://github.com/thegeeklab/wp-gitea-release/blob/main/LICENSE)
|
||||
|
||||
Woodpecker CI plugin to add comments to GitHub Issues and Pull Requests. You can find the full documentation at [https://woodpecker-plugins.geekdocs.de](https://woodpecker-plugins.geekdocs.de/plugins/wp-gitea-release).
|
||||
Woodpecker CI plugin to publish files and artifacts to Gitea releases. You can find the full documentation at [https://woodpecker-plugins.geekdocs.de](https://woodpecker-plugins.geekdocs.de/plugins/wp-gitea-release).
|
||||
|
||||
## Contributors
|
||||
|
||||
|
@ -12,7 +12,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "api-key",
|
||||
Usage: "api key to access gitea api",
|
||||
Usage: "api key to access Gitea API",
|
||||
EnvVars: []string{"PLUGIN_API_KEY", "GITEA_RELEASE_API_KEY", "GITEA_TOKEN"},
|
||||
Destination: &settings.APIKey,
|
||||
Category: category,
|
||||
@ -55,37 +55,24 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "base-url",
|
||||
Usage: "url of the gitea instance",
|
||||
Usage: "URL of the Gitea instance",
|
||||
EnvVars: []string{"PLUGIN_BASE_URL", "GITEA_RELEASE_BASE_URL"},
|
||||
Category: category,
|
||||
Required: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "note",
|
||||
Usage: "file or string with notes for the release (example: changelog)",
|
||||
Usage: "file or string with notes for the release",
|
||||
EnvVars: []string{"PLUGIN_NOTE", "GITEA_RELEASE_NOTE"},
|
||||
Destination: &settings.Note,
|
||||
Category: category,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "title",
|
||||
Usage: "file or string for the title shown in the gitea release",
|
||||
EnvVars: []string{"PLUGIN_TITLE", "GITEA_RELEASE_TITLE"},
|
||||
Usage: "file or string for the title shown in the Gitea release",
|
||||
EnvVars: []string{"PLUGIN_TITLE", "GITEA_RELEASE_TITLE", "CI_COMMIT_TAG"},
|
||||
Destination: &settings.Title,
|
||||
Category: category,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "repo.owner",
|
||||
Usage: "repository owner",
|
||||
EnvVars: []string{"CI_REPO_OWNER"},
|
||||
Destination: &settings.Repo.Owner,
|
||||
Category: category,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "repo.name",
|
||||
Usage: "repository name",
|
||||
EnvVars: []string{"CI_REPO_NAME"},
|
||||
Destination: &settings.Repo.Name,
|
||||
DefaultText: "$CI_COMMIT_TAG",
|
||||
Category: category,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
@ -94,6 +81,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
||||
Usage: "build event",
|
||||
EnvVars: []string{"CI_PIPELINE_EVENT"},
|
||||
Destination: &settings.Event,
|
||||
DefaultText: "$CI_PIPELINE_EVENT",
|
||||
Category: category,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
|
@ -18,7 +18,7 @@ func main() {
|
||||
settings := &plugin.Settings{}
|
||||
options := wp.Options{
|
||||
Name: "wp-gitea-release",
|
||||
Description: "Add comments to GitHub Issues and Pull Requests",
|
||||
Description: "Publish files and artifacts to Gitea releases",
|
||||
Version: BuildVersion,
|
||||
VersionMetadata: fmt.Sprintf("date=%s", BuildDate),
|
||||
Flags: settingsFlags(settings, wp.FlagsPluginCategory),
|
||||
|
@ -10,7 +10,7 @@ title: wp-gitea-release
|
||||
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/wp-gitea-release)
|
||||
[![License: Apache-2.0](https://img.shields.io/github/license/thegeeklab/wp-gitea-release)](https://github.com/thegeeklab/wp-gitea-release/blob/main/LICENSE)
|
||||
|
||||
Woodpecker CI plugin to add comments to GitHub Issues and Pull Requests.
|
||||
Woodpecker CI plugin to publish files and artifacts to Gitea releases.
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
<!-- spellchecker-disable -->
|
||||
@ -20,12 +20,8 @@ Woodpecker CI plugin to add comments to GitHub Issues and Pull Requests.
|
||||
|
||||
## Usage
|
||||
|
||||
{{< hint type=important >}}
|
||||
Due to the nature of this plugin, a secret for the GitHub token may need to be exposed for pull request events in Woodpecker. Please be careful with this option, as a malicious actor may submit a pull request that exposes your secrets. Do not disclose secrets to pull requests in public environments without further protection.
|
||||
{{< /hint >}}
|
||||
|
||||
{{< hint type=note >}}
|
||||
Only pull request events are supported by this plugin. Running the plugin on other events will result in an error.
|
||||
Only tag events are supported by this plugin. Running the plugin on other events will result in an error.
|
||||
{{< /hint >}}
|
||||
|
||||
```YAML
|
||||
@ -33,12 +29,12 @@ kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: pr-comment
|
||||
- name: publish
|
||||
image: quay.io/thegeeklab/wp-gitea-release
|
||||
settings:
|
||||
api_key: ghp_3LbMg9Kncpdkhjp3bh3dMnKNXLjVMTsXk4sM
|
||||
message: "CI run completed successfully"
|
||||
update: true
|
||||
api_key: 3LbMg9Kncpdkhjp3bh3dMnKNXLjVMTsXk4sM
|
||||
base_url: https://gitea.rknet.org
|
||||
files: build/*
|
||||
```
|
||||
|
||||
### Parameters
|
||||
@ -67,12 +63,12 @@ docker build --file Containerfile.multiarch --tag thegeeklab/wp-gitea-release .
|
||||
|
||||
```Shell
|
||||
docker run --rm \
|
||||
-e CI_PIPELINE_EVENT=pull_request \
|
||||
-e CI_REPO_OWNER=octocat \
|
||||
-e CI_REPO_NAME=foo \
|
||||
-e CI_COMMIT_PULL_REQUEST=1
|
||||
-e PLUGIN_API_KEY=abc123 \
|
||||
-e PLUGIN_MESSAGE="Demo comment" \
|
||||
-e PLUGIN_BASE_URL=https://try.gitea.io \
|
||||
-e PLUGIN_API_KEY=your-api-key \
|
||||
-e PLUGIN_FILES=build/* \
|
||||
-e CI_REPO_OWNER=gitea \
|
||||
-e CI_REPO_NAME=test \
|
||||
-e CI_PIPELINE_EVENT=tag \
|
||||
-v $(pwd):/build:z \
|
||||
-w /build \
|
||||
thegeeklab/wp-gitea-release
|
||||
|
@ -2,43 +2,58 @@
|
||||
properties:
|
||||
- name: api_key
|
||||
description: |
|
||||
Personal access token to access the GitHub API.
|
||||
Api key to access Gitea API.
|
||||
type: string
|
||||
required: true
|
||||
|
||||
- name: base_url
|
||||
description: |
|
||||
Api url.
|
||||
|
||||
Only need to be changed for GitHub enterprise in most cases.
|
||||
type: string
|
||||
defaultValue: "https://api.github.com/"
|
||||
required: false
|
||||
|
||||
- name: key
|
||||
description: |
|
||||
Unique identifier to assign to a comment.
|
||||
|
||||
The identifier is used to update an existing comment.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: message
|
||||
description: |
|
||||
Path to file or string that contains the comment text.
|
||||
URL of the Gitea instance.
|
||||
type: string
|
||||
required: true
|
||||
|
||||
- name: skip_missing
|
||||
- name: checksum
|
||||
description: |
|
||||
Skip comment creation if the given message file does not exist.
|
||||
Generate specific checksums.
|
||||
type: list
|
||||
required: false
|
||||
|
||||
- name: draft
|
||||
description: |
|
||||
Create a draft release.
|
||||
type: bool
|
||||
defaultValue: false
|
||||
required: false
|
||||
|
||||
- name: update
|
||||
- name: file_exist
|
||||
description: |
|
||||
Enable update of an existing comment that matches the key.
|
||||
What to do if file already exist.
|
||||
type: string
|
||||
defaultValue: "overwrite"
|
||||
required: false
|
||||
|
||||
- name: files
|
||||
description: |
|
||||
List of files to upload.
|
||||
type: list
|
||||
required: false
|
||||
|
||||
- name: note
|
||||
description: |
|
||||
File or string with notes for the release.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
- name: prerelease
|
||||
description: |
|
||||
Set the release as prerelease.
|
||||
type: bool
|
||||
defaultValue: false
|
||||
required: false
|
||||
|
||||
- name: title
|
||||
description: |
|
||||
File or string for the title shown in the Gitea release.
|
||||
type: string
|
||||
defaultValue: $CI_COMMIT_TAG
|
||||
required: false
|
||||
|
@ -82,8 +82,8 @@ func (p *Plugin) Execute() error {
|
||||
|
||||
rc := releaseClient{
|
||||
Client: client,
|
||||
Owner: p.Settings.Repo.Owner,
|
||||
Repo: p.Settings.Repo.Name,
|
||||
Owner: p.Metadata.Repository.Owner,
|
||||
Repo: p.Metadata.Repository.Name,
|
||||
Tag: strings.TrimPrefix(p.Settings.CommitRef, "refs/tags/"),
|
||||
Draft: p.Settings.Draft,
|
||||
Prerelease: p.Settings.PreRelease,
|
||||
@ -92,12 +92,6 @@ func (p *Plugin) Execute() error {
|
||||
Note: p.Settings.Note,
|
||||
}
|
||||
|
||||
// if the title was not provided via .drone.yml we use the tag instead
|
||||
// fixes https://github.com/drone-plugins/drone-gitea-release/issues/26
|
||||
if rc.Title == "" {
|
||||
rc.Title = rc.Tag
|
||||
}
|
||||
|
||||
release, err := rc.buildRelease()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create the release: %w", err)
|
||||
|
@ -27,13 +27,6 @@ type Settings struct {
|
||||
|
||||
baseURL *url.URL
|
||||
files []string
|
||||
|
||||
Repo Repo
|
||||
}
|
||||
|
||||
type Repo struct {
|
||||
Owner string
|
||||
Name string
|
||||
}
|
||||
|
||||
func New(options wp.Options, settings *Settings) *Plugin {
|
||||
|
@ -15,7 +15,7 @@ var (
|
||||
ErrFileExists = errors.New("asset file already exist")
|
||||
)
|
||||
|
||||
// Release holds ties the drone env data and gitea client together.
|
||||
// Release holds ties the Woodpecker env data and gitea client together.
|
||||
type releaseClient struct {
|
||||
*gitea.Client
|
||||
Owner string
|
||||
|
Loading…
Reference in New Issue
Block a user