Skip to content

Commit

Permalink
docs: cleanup docs and parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxys committed Jan 4, 2024
1 parent 95511ca commit 9980b66
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/settings.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion .woodpecker/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand Down
26 changes: 7 additions & 19 deletions cmd/wp-gitea-release/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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{
Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion cmd/wp-gitea-release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
28 changes: 12 additions & 16 deletions docs/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand All @@ -20,25 +20,21 @@ 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
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
Expand Down Expand Up @@ -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
Expand Down
49 changes: 32 additions & 17 deletions docs/data/data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
URL of the Gitea instance.
type: string
defaultValue: "https://api.github.com/"
required: true

- name: checksum
description: |
Generate specific checksums.
type: list
required: false

- name: key
- name: draft
description: |
Unique identifier to assign to a comment.
Create a draft release.
type: bool
defaultValue: false
required: false

The identifier is used to update an existing comment.
- name: file_exist
description: |
What to do if file already exist.
type: string
defaultValue: "overwrite"
required: false

- name: message
- name: files
description: |
Path to file or string that contains the comment text.
List of files to upload.
type: list
required: false

- name: note
description: |
File or string with notes for the release.
type: string
required: true
required: false

- name: skip_missing
- name: prerelease
description: |
Skip comment creation if the given message file does not exist.
Set the release as prerelease.
type: bool
defaultValue: false
required: false

- name: update
- name: title
description: |
Enable update of an existing comment that matches the key.
type: bool
defaultValue: false
File or string for the title shown in the Gitea release.
type: string
defaultValue: $CI_COMMIT_TAG
required: false
10 changes: 2 additions & 8 deletions plugin/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion plugin/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9980b66

Please sign in to comment.