from file
This commit is contained in:
parent
fcd7f83555
commit
7ad3a171c0
2 changed files with 40 additions and 42 deletions
|
@ -1,46 +1,32 @@
|
||||||
pipeline:
|
steps:
|
||||||
lint-go:
|
- name: publish_image
|
||||||
image: golangci/golangci-lint
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
group: lint-build
|
|
||||||
commands:
|
|
||||||
- golangci-lint run *.go --enable=gofumpt
|
|
||||||
when:
|
|
||||||
path: "*.go"
|
|
||||||
lint-docker:
|
|
||||||
image: hadolint/hadolint:latest-debian
|
|
||||||
group: lint-build
|
|
||||||
commands:
|
|
||||||
- hadolint --ignore DL3003 Dockerfile
|
|
||||||
when:
|
|
||||||
path: "Dockerfile"
|
|
||||||
build-go:
|
|
||||||
image: golang
|
|
||||||
group: lint-build
|
|
||||||
commands:
|
|
||||||
- go build
|
|
||||||
when:
|
|
||||||
path: ["Dockerfile", "*.go"]
|
|
||||||
build-docker-pr:
|
|
||||||
image: plugins/kaniko
|
|
||||||
settings:
|
settings:
|
||||||
repo: mcs94/gitea-comment
|
repo: git.gnous.eu/${CI_REPO_OWNER}/gitea-comment-plugin
|
||||||
tags: latest
|
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
no_push: true
|
platforms: linux/amd64
|
||||||
when:
|
registry: https://git.gnous.eu
|
||||||
event: pull_request
|
tag: ${CI_COMMIT}
|
||||||
branch: main
|
username:
|
||||||
path: ["Dockerfile", "*.go"]
|
from_secret: docker_username
|
||||||
build-docker:
|
|
||||||
image: plugins/kaniko
|
|
||||||
settings:
|
|
||||||
repo: mcs94/gitea-comment
|
|
||||||
tags: latest
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
username: mcs94
|
|
||||||
password:
|
password:
|
||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
when:
|
when:
|
||||||
event: [push, tag]
|
branch: ${CI_REPO_DEFAULT_BRANCH}
|
||||||
branch: main
|
event: push
|
||||||
path: ["Dockerfile", "*.go"]
|
- name: publish_image_tag
|
||||||
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
|
settings:
|
||||||
|
repo: git.gnous.eu/${CI_REPO_OWNER}/gitea-comment-plugin
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
registry: https://git.gnous.eu
|
||||||
|
tags:
|
||||||
|
- ${CI_COMMIT_TAG##v} # Remove v from tag
|
||||||
|
- stable
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
when:
|
||||||
|
event: tag
|
14
main.go
14
main.go
|
@ -37,6 +37,7 @@ func main() {
|
||||||
var giteaToken string
|
var giteaToken string
|
||||||
var giteaAddress string
|
var giteaAddress string
|
||||||
var comment string
|
var comment string
|
||||||
|
var commentFile string
|
||||||
var repoOwner string
|
var repoOwner string
|
||||||
var repoName string
|
var repoName string
|
||||||
var prIndex int
|
var prIndex int
|
||||||
|
@ -44,15 +45,26 @@ func main() {
|
||||||
flag.StringVar(&giteaToken, "gitea-token", LookupEnvOrString("PLUGIN_GITEA_TOKEN", giteaToken), "API token for Gitea")
|
flag.StringVar(&giteaToken, "gitea-token", LookupEnvOrString("PLUGIN_GITEA_TOKEN", giteaToken), "API token for Gitea")
|
||||||
flag.StringVar(&giteaAddress, "gitea-address", LookupEnvOrString("PLUGIN_GITEA_ADDRESS", giteaAddress), "Gitea URL")
|
flag.StringVar(&giteaAddress, "gitea-address", LookupEnvOrString("PLUGIN_GITEA_ADDRESS", giteaAddress), "Gitea URL")
|
||||||
flag.StringVar(&comment, "comment", LookupEnvOrString("PLUGIN_COMMENT", comment), "Comment for Gitea")
|
flag.StringVar(&comment, "comment", LookupEnvOrString("PLUGIN_COMMENT", comment), "Comment for Gitea")
|
||||||
|
flag.StringVar(&commentFile, "comment-file", LookupEnvOrString("PLUGIN_COMMENT_FILE", commentFile), "Comment file for Gitea")
|
||||||
flag.StringVar(&repoOwner, "repo-owner", LookupEnvOrString("CI_REPO_OWNER", repoOwner), "Owner of the repository")
|
flag.StringVar(&repoOwner, "repo-owner", LookupEnvOrString("CI_REPO_OWNER", repoOwner), "Owner of the repository")
|
||||||
flag.StringVar(&repoName, "repo-name", LookupEnvOrString("CI_REPO_NAME", repoName), "Name of the repository")
|
flag.StringVar(&repoName, "repo-name", LookupEnvOrString("CI_REPO_NAME", repoName), "Name of the repository")
|
||||||
flag.IntVar(&prIndex, "pr-index", LookupEnvOrInt("CI_COMMIT_PULL_REQUEST", prIndex), "Index of the PR")
|
flag.IntVar(&prIndex, "pr-index", LookupEnvOrInt("CI_COMMIT_PULL_REQUEST", prIndex), "Index of the PR")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if comment == "" {
|
if comment == "" || commentFile != "" {
|
||||||
panic("You must provide a comment")
|
panic("You must provide a comment")
|
||||||
}
|
}
|
||||||
|
if commentFile != "" && comment != "" {
|
||||||
|
panic("You must provide only one of comment or comment-file")
|
||||||
|
}
|
||||||
|
if commentFile != "" {
|
||||||
|
commentBytes, err := os.ReadFile(commentFile)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
comment = string(commentBytes)
|
||||||
|
}
|
||||||
if giteaToken == "" {
|
if giteaToken == "" {
|
||||||
panic("You must provide a Gitea API Token")
|
panic("You must provide a Gitea API Token")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue