mirror of
https://github.com/thegeeklab/wp-git-action.git
synced 2024-11-23 06:20:38 +00:00
initial commit after fork
This commit is contained in:
parent
cc621215e3
commit
873a7c6437
23
.chglog/CHANGELOG.tpl.md
Executable file
23
.chglog/CHANGELOG.tpl.md
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
{{ range .Versions -}}
|
||||||
|
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})
|
||||||
|
|
||||||
|
{{ range .CommitGroups -}}
|
||||||
|
### {{ .Title }}
|
||||||
|
|
||||||
|
{{ range .Commits -}}
|
||||||
|
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ (regexReplaceAll "(.*)/issues/(.*)" (regexReplaceAll "(Co-\\w*-by.*)" .Subject "") "${1}/pull/${2}") | trim }}
|
||||||
|
{{ end }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- if .NoteGroups -}}
|
||||||
|
{{ range .NoteGroups -}}
|
||||||
|
### {{ .Title }}
|
||||||
|
|
||||||
|
{{ range .Notes }}
|
||||||
|
{{ .Body }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
{{ end -}}
|
25
.chglog/config.yml
Executable file
25
.chglog/config.yml
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
style: github
|
||||||
|
template: CHANGELOG.tpl.md
|
||||||
|
info:
|
||||||
|
title: CHANGELOG
|
||||||
|
repository_url: https://github.com/thegeeklab/drone-git-action
|
||||||
|
options:
|
||||||
|
commit_groups:
|
||||||
|
title_maps:
|
||||||
|
feat: Features
|
||||||
|
fix: Bug Fixes
|
||||||
|
perf: Performance Improvements
|
||||||
|
refactor: Code Refactoring
|
||||||
|
chore: Others
|
||||||
|
test: Testing
|
||||||
|
ci: CI Pipeline
|
||||||
|
docs: Documentation
|
||||||
|
header:
|
||||||
|
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
|
||||||
|
pattern_maps:
|
||||||
|
- Type
|
||||||
|
- Scope
|
||||||
|
- Subject
|
||||||
|
notes:
|
||||||
|
keywords:
|
||||||
|
- BREAKING CHANGE
|
5
.dictionary
Normal file
5
.dictionary
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
api
|
||||||
|
github
|
||||||
|
url
|
||||||
|
gh
|
||||||
|
drone-git-action
|
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!dist/
|
@ -1,2 +0,0 @@
|
|||||||
*
|
|
||||||
!release/
|
|
360
.drone.jsonnet
360
.drone.jsonnet
@ -1,14 +1,352 @@
|
|||||||
local pipeline = import 'pipeline.libsonnet';
|
local PipelineTest = {
|
||||||
local name = 'drone-git-action';
|
kind: 'pipeline',
|
||||||
|
name: 'test',
|
||||||
|
platform: {
|
||||||
|
os: 'linux',
|
||||||
|
arch: 'amd64',
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
name: 'deps',
|
||||||
|
image: 'golang:1.19',
|
||||||
|
commands: [
|
||||||
|
'make deps',
|
||||||
|
],
|
||||||
|
volumes: [
|
||||||
|
{
|
||||||
|
name: 'godeps',
|
||||||
|
path: '/go',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'lint',
|
||||||
|
image: 'golang:1.19',
|
||||||
|
commands: [
|
||||||
|
'make lint',
|
||||||
|
],
|
||||||
|
volumes: [
|
||||||
|
{
|
||||||
|
name: 'godeps',
|
||||||
|
path: '/go',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'test',
|
||||||
|
image: 'golang:1.19',
|
||||||
|
commands: [
|
||||||
|
'make test',
|
||||||
|
],
|
||||||
|
volumes: [
|
||||||
|
{
|
||||||
|
name: 'godeps',
|
||||||
|
path: '/go',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
volumes: [
|
||||||
|
{
|
||||||
|
name: 'godeps',
|
||||||
|
temp: {},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
trigger: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
local PipelineBuildBinaries = {
|
||||||
|
kind: 'pipeline',
|
||||||
|
name: 'build-binaries',
|
||||||
|
platform: {
|
||||||
|
os: 'linux',
|
||||||
|
arch: 'amd64',
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
name: 'build',
|
||||||
|
image: 'techknowlogick/xgo:go-1.19.x',
|
||||||
|
commands: [
|
||||||
|
'ln -s /drone/src /source',
|
||||||
|
'make release',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'executable',
|
||||||
|
image: 'alpine',
|
||||||
|
commands: [
|
||||||
|
'$(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'changelog-generate',
|
||||||
|
image: 'thegeeklab/git-chglog',
|
||||||
|
commands: [
|
||||||
|
'git fetch -tq',
|
||||||
|
'git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'changelog-format',
|
||||||
|
image: 'thegeeklab/alpine-tools',
|
||||||
|
commands: [
|
||||||
|
'prettier CHANGELOG.md',
|
||||||
|
'prettier -w CHANGELOG.md',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'publish',
|
||||||
|
image: 'plugins/github-release',
|
||||||
|
settings: {
|
||||||
|
overwrite: true,
|
||||||
|
api_key: {
|
||||||
|
from_secret: 'github_token',
|
||||||
|
},
|
||||||
|
files: ['dist/*'],
|
||||||
|
title: '${DRONE_TAG}',
|
||||||
|
note: 'CHANGELOG.md',
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
ref: [
|
||||||
|
'refs/tags/**',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
depends_on: [
|
||||||
|
'test',
|
||||||
|
],
|
||||||
|
trigger: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
local PipelineBuildContainer(arch='amd64') = {
|
||||||
|
kind: 'pipeline',
|
||||||
|
name: 'build-container-' + arch,
|
||||||
|
platform: {
|
||||||
|
os: 'linux',
|
||||||
|
arch: arch,
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
name: 'build',
|
||||||
|
image: 'golang:1.19',
|
||||||
|
commands: [
|
||||||
|
'make build',
|
||||||
|
'ls -l dist/drone-git-action',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'dryrun',
|
||||||
|
image: 'thegeeklab/drone-docker:19',
|
||||||
|
settings: {
|
||||||
|
dry_run: true,
|
||||||
|
dockerfile: 'docker/Dockerfile.' + arch,
|
||||||
|
repo: 'thegeeklab/${DRONE_REPO_NAME}',
|
||||||
|
},
|
||||||
|
depends_on: ['build'],
|
||||||
|
when: {
|
||||||
|
ref: ['refs/pull/**'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'publish-dockerhub',
|
||||||
|
image: 'thegeeklab/drone-docker:19',
|
||||||
|
settings: {
|
||||||
|
auto_tag: true,
|
||||||
|
auto_tag_suffix: arch,
|
||||||
|
dockerfile: 'docker/Dockerfile.' + arch,
|
||||||
|
repo: 'thegeeklab/${DRONE_REPO_NAME}',
|
||||||
|
username: { from_secret: 'docker_username' },
|
||||||
|
password: { from_secret: 'docker_password' },
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**'],
|
||||||
|
},
|
||||||
|
depends_on: ['dryrun'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'publish-quay',
|
||||||
|
image: 'thegeeklab/drone-docker:19',
|
||||||
|
settings: {
|
||||||
|
auto_tag: true,
|
||||||
|
auto_tag_suffix: arch,
|
||||||
|
dockerfile: 'docker/Dockerfile.' + arch,
|
||||||
|
registry: 'quay.io',
|
||||||
|
repo: 'quay.io/thegeeklab/${DRONE_REPO_NAME}',
|
||||||
|
username: { from_secret: 'quay_username' },
|
||||||
|
password: { from_secret: 'quay_password' },
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**'],
|
||||||
|
},
|
||||||
|
depends_on: ['dryrun'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
depends_on: [
|
||||||
|
'test',
|
||||||
|
],
|
||||||
|
trigger: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
local PipelineDocs = {
|
||||||
|
kind: 'pipeline',
|
||||||
|
name: 'docs',
|
||||||
|
platform: {
|
||||||
|
os: 'linux',
|
||||||
|
arch: 'amd64',
|
||||||
|
},
|
||||||
|
concurrency: {
|
||||||
|
limit: 1,
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
name: 'markdownlint',
|
||||||
|
image: 'thegeeklab/markdownlint-cli',
|
||||||
|
commands: [
|
||||||
|
"markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md'",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'spellcheck',
|
||||||
|
image: 'thegeeklab/alpine-tools',
|
||||||
|
commands: [
|
||||||
|
"spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions",
|
||||||
|
],
|
||||||
|
environment: {
|
||||||
|
FORCE_COLOR: true,
|
||||||
|
NPM_CONFIG_LOGLEVEL: 'error',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'publish',
|
||||||
|
image: 'plugins/gh-pages',
|
||||||
|
settings: {
|
||||||
|
username: { from_secret: 'github_username' },
|
||||||
|
password: { from_secret: 'github_token' },
|
||||||
|
pages_directory: '_docs/',
|
||||||
|
target_branch: 'docs',
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
ref: ['refs/heads/main'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
depends_on: [
|
||||||
|
'build-binaries',
|
||||||
|
'build-container-amd64',
|
||||||
|
'build-container-arm64',
|
||||||
|
'build-container-arm',
|
||||||
|
],
|
||||||
|
trigger: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
local PipelineNotifications = {
|
||||||
|
kind: 'pipeline',
|
||||||
|
name: 'notifications',
|
||||||
|
platform: {
|
||||||
|
os: 'linux',
|
||||||
|
arch: 'amd64',
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
image: 'plugins/manifest',
|
||||||
|
name: 'manifest-dockerhub',
|
||||||
|
settings: {
|
||||||
|
ignore_missing: true,
|
||||||
|
auto_tag: true,
|
||||||
|
username: { from_secret: 'docker_username' },
|
||||||
|
password: { from_secret: 'docker_password' },
|
||||||
|
spec: 'docker/manifest.tmpl',
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
status: ['success'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
image: 'plugins/manifest',
|
||||||
|
name: 'manifest-quay',
|
||||||
|
settings: {
|
||||||
|
ignore_missing: true,
|
||||||
|
auto_tag: true,
|
||||||
|
username: { from_secret: 'quay_username' },
|
||||||
|
password: { from_secret: 'quay_password' },
|
||||||
|
spec: 'docker/manifest-quay.tmpl',
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
status: ['success'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'pushrm-dockerhub',
|
||||||
|
image: 'chko/docker-pushrm:1',
|
||||||
|
environment: {
|
||||||
|
DOCKER_PASS: {
|
||||||
|
from_secret: 'docker_password',
|
||||||
|
},
|
||||||
|
DOCKER_USER: {
|
||||||
|
from_secret: 'docker_username',
|
||||||
|
},
|
||||||
|
PUSHRM_FILE: 'README.md',
|
||||||
|
PUSHRM_SHORT: 'Drone plugin to execute git actions',
|
||||||
|
PUSHRM_TARGET: 'thegeeklab/${DRONE_REPO_NAME}',
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
status: ['success'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'pushrm-quay',
|
||||||
|
image: 'chko/docker-pushrm:1',
|
||||||
|
environment: {
|
||||||
|
APIKEY__QUAY_IO: {
|
||||||
|
from_secret: 'quay_token',
|
||||||
|
},
|
||||||
|
PUSHRM_FILE: 'README.md',
|
||||||
|
PUSHRM_TARGET: 'quay.io/thegeeklab/${DRONE_REPO_NAME}',
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
status: ['success'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'matrix',
|
||||||
|
image: 'thegeeklab/drone-matrix',
|
||||||
|
settings: {
|
||||||
|
homeserver: { from_secret: 'matrix_homeserver' },
|
||||||
|
roomid: { from_secret: 'matrix_roomid' },
|
||||||
|
template: 'Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}',
|
||||||
|
username: { from_secret: 'matrix_username' },
|
||||||
|
password: { from_secret: 'matrix_password' },
|
||||||
|
},
|
||||||
|
when: {
|
||||||
|
status: ['success', 'failure'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
depends_on: [
|
||||||
|
'docs',
|
||||||
|
],
|
||||||
|
trigger: {
|
||||||
|
ref: ['refs/heads/main', 'refs/tags/**'],
|
||||||
|
status: ['success', 'failure'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
[
|
[
|
||||||
pipeline.test('linux', 'amd64'),
|
PipelineTest,
|
||||||
pipeline.build(name, 'linux', 'amd64'),
|
PipelineBuildBinaries,
|
||||||
pipeline.build(name, 'linux', 'arm64'),
|
PipelineBuildContainer(arch='amd64'),
|
||||||
pipeline.build(name, 'linux', 'arm'),
|
PipelineBuildContainer(arch='arm64'),
|
||||||
pipeline.notifications(depends_on=[
|
PipelineBuildContainer(arch='arm'),
|
||||||
'linux-amd64',
|
PipelineDocs,
|
||||||
'linux-arm64',
|
PipelineNotifications,
|
||||||
'linux-arm',
|
|
||||||
]),
|
|
||||||
]
|
]
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
local pipeline = import 'pipeline.libsonnet';
|
|
||||||
local name = 'drone-git-action';
|
|
||||||
|
|
||||||
[
|
|
||||||
pipeline.test('windows', 'amd64', '1803'),
|
|
||||||
pipeline.build(name, 'windows', 'amd64', '1803'),
|
|
||||||
pipeline.build(name, 'windows', 'amd64', '1809'),
|
|
||||||
pipeline.notifications('windows', 'amd64', '1809', ['windows-1803', 'windows-1809']),
|
|
||||||
]
|
|
@ -1,273 +0,0 @@
|
|||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: testing
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: windows
|
|
||||||
arch: amd64
|
|
||||||
version: 1803
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: vet
|
|
||||||
pull: always
|
|
||||||
image: golang:1.11-windowsservercore-1803
|
|
||||||
commands:
|
|
||||||
- go vet ./...
|
|
||||||
environment:
|
|
||||||
GO111MODULE: on
|
|
||||||
volumes:
|
|
||||||
- name: gopath
|
|
||||||
path: C:\\gopath
|
|
||||||
|
|
||||||
- name: test
|
|
||||||
pull: always
|
|
||||||
image: golang:1.11-windowsservercore-1803
|
|
||||||
commands:
|
|
||||||
- go test -cover ./...
|
|
||||||
environment:
|
|
||||||
GO111MODULE: on
|
|
||||||
volumes:
|
|
||||||
- name: gopath
|
|
||||||
path: C:\\gopath
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: gopath
|
|
||||||
temp: {}
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- "refs/tags/**"
|
|
||||||
- "refs/pull/**"
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: windows-1803
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: windows
|
|
||||||
arch: amd64
|
|
||||||
version: 1803
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build-push
|
|
||||||
pull: always
|
|
||||||
image: golang:1.11-windowsservercore-1803
|
|
||||||
commands:
|
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-git-action.exe"
|
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
GO111MODULE: on
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: build-tag
|
|
||||||
pull: always
|
|
||||||
image: golang:1.11-windowsservercore-1803
|
|
||||||
commands:
|
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-git-action.exe"
|
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
GO111MODULE: on
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: executable
|
|
||||||
pull: always
|
|
||||||
image: golang:1.11-windowsservercore-1803
|
|
||||||
commands:
|
|
||||||
- ./release/windows/amd64/drone-git-action.exe --help
|
|
||||||
|
|
||||||
- name: dryrun
|
|
||||||
pull: always
|
|
||||||
image: plugins/docker:windows-1803
|
|
||||||
settings:
|
|
||||||
daemon_off: true
|
|
||||||
dockerfile: docker/Dockerfile.windows.1803
|
|
||||||
dry_run: true
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: plugins/git-action
|
|
||||||
tags: windows-1803
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
volumes:
|
|
||||||
- name: docker_pipe
|
|
||||||
path: \\\\.\\pipe\\docker_engine
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
- name: publish
|
|
||||||
pull: always
|
|
||||||
image: plugins/docker:windows-1803
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: windows-1803
|
|
||||||
daemon_off: true
|
|
||||||
dockerfile: docker/Dockerfile.windows.1803
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: plugins/git-action
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
volumes:
|
|
||||||
- name: docker_pipe
|
|
||||||
path: \\\\.\\pipe\\docker_engine
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: docker_pipe
|
|
||||||
host:
|
|
||||||
path: \\\\.\\pipe\\docker_engine
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- "refs/tags/**"
|
|
||||||
- "refs/pull/**"
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- testing
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: windows-1809
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: windows
|
|
||||||
arch: amd64
|
|
||||||
version: 1809
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build-push
|
|
||||||
pull: always
|
|
||||||
image: golang:1.11-windowsservercore-1809
|
|
||||||
commands:
|
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-git-action.exe"
|
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
GO111MODULE: on
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: build-tag
|
|
||||||
pull: always
|
|
||||||
image: golang:1.11-windowsservercore-1809
|
|
||||||
commands:
|
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-git-action.exe"
|
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
GO111MODULE: on
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: executable
|
|
||||||
pull: always
|
|
||||||
image: golang:1.11-windowsservercore-1809
|
|
||||||
commands:
|
|
||||||
- ./release/windows/amd64/drone-git-action.exe --help
|
|
||||||
|
|
||||||
- name: dryrun
|
|
||||||
pull: always
|
|
||||||
image: plugins/docker:windows-1809
|
|
||||||
settings:
|
|
||||||
daemon_off: true
|
|
||||||
dockerfile: docker/Dockerfile.windows.1809
|
|
||||||
dry_run: true
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: plugins/git-action
|
|
||||||
tags: windows-1809
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
volumes:
|
|
||||||
- name: docker_pipe
|
|
||||||
path: \\\\.\\pipe\\docker_engine
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
- name: publish
|
|
||||||
pull: always
|
|
||||||
image: plugins/docker:windows-1809
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: windows-1809
|
|
||||||
daemon_off: true
|
|
||||||
dockerfile: docker/Dockerfile.windows.1809
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: plugins/git-action
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
volumes:
|
|
||||||
- name: docker_pipe
|
|
||||||
path: \\\\.\\pipe\\docker_engine
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: docker_pipe
|
|
||||||
host:
|
|
||||||
path: \\\\.\\pipe\\docker_engine
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- "refs/tags/**"
|
|
||||||
- "refs/pull/**"
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- testing
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: notifications
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: windows
|
|
||||||
arch: amd64
|
|
||||||
version: 1809
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: manifest
|
|
||||||
pull: always
|
|
||||||
image: plugins/manifest
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
ignore_missing: true
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
spec: docker/manifest.tmpl
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
|
|
||||||
- name: microbadger
|
|
||||||
pull: always
|
|
||||||
image: plugins/webhook
|
|
||||||
settings:
|
|
||||||
urls:
|
|
||||||
from_secret: microbadger_url
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- "refs/tags/**"
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- windows-1803
|
|
||||||
- windows-1809
|
|
||||||
|
|
||||||
...
|
|
626
.drone.yml
626
.drone.yml
@ -1,295 +1,369 @@
|
|||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: testing
|
name: test
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
os: linux
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: vet
|
- name: deps
|
||||||
pull: always
|
image: golang:1.19
|
||||||
image: golang:1.11
|
commands:
|
||||||
commands:
|
- make deps
|
||||||
- go vet ./...
|
volumes:
|
||||||
environment:
|
- name: godeps
|
||||||
GO111MODULE: on
|
path: /go
|
||||||
volumes:
|
|
||||||
- name: gopath
|
|
||||||
path: /go
|
|
||||||
|
|
||||||
- name: test
|
- name: lint
|
||||||
pull: always
|
image: golang:1.19
|
||||||
image: golang:1.11
|
commands:
|
||||||
commands:
|
- make lint
|
||||||
- go test -cover ./...
|
volumes:
|
||||||
environment:
|
- name: godeps
|
||||||
GO111MODULE: on
|
path: /go
|
||||||
volumes:
|
|
||||||
- name: gopath
|
- name: test
|
||||||
path: /go
|
image: golang:1.19
|
||||||
|
commands:
|
||||||
|
- make test
|
||||||
|
volumes:
|
||||||
|
- name: godeps
|
||||||
|
path: /go
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: gopath
|
- name: godeps
|
||||||
temp: {}
|
temp: {}
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/main
|
||||||
- "refs/tags/**"
|
- refs/tags/**
|
||||||
- "refs/pull/**"
|
- refs/pull/**
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: linux-amd64
|
name: build-binaries
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
os: linux
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build-push
|
- name: build
|
||||||
pull: always
|
image: techknowlogick/xgo:go-1.19.x
|
||||||
image: golang:1.11
|
commands:
|
||||||
commands:
|
- ln -s /drone/src /source
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-git-action"
|
- make release
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
GO111MODULE: on
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: build-tag
|
- name: executable
|
||||||
pull: always
|
image: alpine
|
||||||
image: golang:1.11
|
commands:
|
||||||
commands:
|
- $(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-git-action"
|
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
GO111MODULE: on
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: executable
|
- name: changelog-generate
|
||||||
pull: always
|
image: thegeeklab/git-chglog
|
||||||
image: golang:1.11
|
commands:
|
||||||
commands:
|
- git fetch -tq
|
||||||
- ./release/linux/amd64/drone-git-action --help
|
- git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}
|
||||||
|
|
||||||
- name: dryrun
|
- name: changelog-format
|
||||||
pull: always
|
image: thegeeklab/alpine-tools
|
||||||
image: plugins/docker:linux-amd64
|
commands:
|
||||||
settings:
|
- prettier CHANGELOG.md
|
||||||
daemon_off: false
|
- prettier -w CHANGELOG.md
|
||||||
dockerfile: docker/Dockerfile.linux.amd64
|
|
||||||
dry_run: true
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: plugins/git-action
|
|
||||||
tags: linux-amd64
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
- name: publish
|
- name: publish
|
||||||
pull: always
|
image: plugins/github-release
|
||||||
image: plugins/docker:linux-amd64
|
settings:
|
||||||
settings:
|
api_key:
|
||||||
auto_tag: true
|
from_secret: github_token
|
||||||
auto_tag_suffix: linux-amd64
|
files:
|
||||||
daemon_off: false
|
- dist/*
|
||||||
dockerfile: docker/Dockerfile.linux.amd64
|
note: CHANGELOG.md
|
||||||
password:
|
overwrite: true
|
||||||
from_secret: docker_password
|
title: ${DRONE_TAG}
|
||||||
repo: plugins/git-action
|
when:
|
||||||
username:
|
ref:
|
||||||
from_secret: docker_username
|
- refs/tags/**
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/main
|
||||||
- "refs/tags/**"
|
- refs/tags/**
|
||||||
- "refs/pull/**"
|
- refs/pull/**
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- testing
|
- test
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: linux-arm64
|
name: build-container-amd64
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: golang:1.19
|
||||||
|
commands:
|
||||||
|
- make build
|
||||||
|
- ls -l dist/drone-git-action
|
||||||
|
|
||||||
|
- name: dryrun
|
||||||
|
image: thegeeklab/drone-docker:19
|
||||||
|
settings:
|
||||||
|
dockerfile: docker/Dockerfile.amd64
|
||||||
|
dry_run: true
|
||||||
|
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/pull/**
|
||||||
|
depends_on:
|
||||||
|
- build
|
||||||
|
|
||||||
|
- name: publish-dockerhub
|
||||||
|
image: thegeeklab/drone-docker:19
|
||||||
|
settings:
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: amd64
|
||||||
|
dockerfile: docker/Dockerfile.amd64
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
depends_on:
|
||||||
|
- dryrun
|
||||||
|
|
||||||
|
- name: publish-quay
|
||||||
|
image: thegeeklab/drone-docker:19
|
||||||
|
settings:
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: amd64
|
||||||
|
dockerfile: docker/Dockerfile.amd64
|
||||||
|
password:
|
||||||
|
from_secret: quay_password
|
||||||
|
registry: quay.io
|
||||||
|
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
username:
|
||||||
|
from_secret: quay_username
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
depends_on:
|
||||||
|
- dryrun
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
- refs/pull/**
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- test
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: build-container-arm64
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
os: linux
|
||||||
arch: arm64
|
arch: arm64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build-push
|
- name: build
|
||||||
pull: always
|
image: golang:1.19
|
||||||
image: golang:1.11
|
commands:
|
||||||
commands:
|
- make build
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-git-action"
|
- ls -l dist/drone-git-action
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
GO111MODULE: on
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: build-tag
|
- name: dryrun
|
||||||
pull: always
|
image: thegeeklab/drone-docker:19
|
||||||
image: golang:1.11
|
settings:
|
||||||
commands:
|
dockerfile: docker/Dockerfile.arm64
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-git-action"
|
dry_run: true
|
||||||
environment:
|
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||||
CGO_ENABLED: 0
|
when:
|
||||||
GO111MODULE: on
|
ref:
|
||||||
when:
|
- refs/pull/**
|
||||||
event:
|
depends_on:
|
||||||
- tag
|
- build
|
||||||
|
|
||||||
- name: executable
|
- name: publish-dockerhub
|
||||||
pull: always
|
image: thegeeklab/drone-docker:19
|
||||||
image: golang:1.11
|
settings:
|
||||||
commands:
|
auto_tag: true
|
||||||
- ./release/linux/arm64/drone-git-action --help
|
auto_tag_suffix: arm64
|
||||||
|
dockerfile: docker/Dockerfile.arm64
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
depends_on:
|
||||||
|
- dryrun
|
||||||
|
|
||||||
- name: dryrun
|
- name: publish-quay
|
||||||
pull: always
|
image: thegeeklab/drone-docker:19
|
||||||
image: plugins/docker:linux-arm64
|
settings:
|
||||||
settings:
|
auto_tag: true
|
||||||
daemon_off: false
|
auto_tag_suffix: arm64
|
||||||
dockerfile: docker/Dockerfile.linux.arm64
|
dockerfile: docker/Dockerfile.arm64
|
||||||
dry_run: true
|
password:
|
||||||
password:
|
from_secret: quay_password
|
||||||
from_secret: docker_password
|
registry: quay.io
|
||||||
repo: plugins/git-action
|
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
||||||
tags: linux-arm64
|
username:
|
||||||
username:
|
from_secret: quay_username
|
||||||
from_secret: docker_username
|
when:
|
||||||
when:
|
ref:
|
||||||
event:
|
- refs/heads/main
|
||||||
- pull_request
|
- refs/tags/**
|
||||||
|
depends_on:
|
||||||
- name: publish
|
- dryrun
|
||||||
pull: always
|
|
||||||
image: plugins/docker:linux-arm64
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: linux-arm64
|
|
||||||
daemon_off: false
|
|
||||||
dockerfile: docker/Dockerfile.linux.arm64
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: plugins/git-action
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/main
|
||||||
- "refs/tags/**"
|
- refs/tags/**
|
||||||
- "refs/pull/**"
|
- refs/pull/**
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- testing
|
- test
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: linux-arm
|
name: build-container-arm
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
os: linux
|
||||||
arch: arm
|
arch: arm
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build-push
|
- name: build
|
||||||
pull: always
|
image: golang:1.19
|
||||||
image: golang:1.11
|
commands:
|
||||||
commands:
|
- make build
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-git-action"
|
- ls -l dist/drone-git-action
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
GO111MODULE: on
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: build-tag
|
- name: dryrun
|
||||||
pull: always
|
image: thegeeklab/drone-docker:19
|
||||||
image: golang:1.11
|
settings:
|
||||||
commands:
|
dockerfile: docker/Dockerfile.arm
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-git-action"
|
dry_run: true
|
||||||
environment:
|
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||||
CGO_ENABLED: 0
|
when:
|
||||||
GO111MODULE: on
|
ref:
|
||||||
when:
|
- refs/pull/**
|
||||||
event:
|
depends_on:
|
||||||
- tag
|
- build
|
||||||
|
|
||||||
- name: executable
|
- name: publish-dockerhub
|
||||||
pull: always
|
image: thegeeklab/drone-docker:19
|
||||||
image: golang:1.11
|
settings:
|
||||||
commands:
|
auto_tag: true
|
||||||
- ./release/linux/arm/drone-git-action --help
|
auto_tag_suffix: arm
|
||||||
|
dockerfile: docker/Dockerfile.arm
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
depends_on:
|
||||||
|
- dryrun
|
||||||
|
|
||||||
- name: dryrun
|
- name: publish-quay
|
||||||
pull: always
|
image: thegeeklab/drone-docker:19
|
||||||
image: plugins/docker:linux-arm
|
settings:
|
||||||
settings:
|
auto_tag: true
|
||||||
daemon_off: false
|
auto_tag_suffix: arm
|
||||||
dockerfile: docker/Dockerfile.linux.arm
|
dockerfile: docker/Dockerfile.arm
|
||||||
dry_run: true
|
password:
|
||||||
password:
|
from_secret: quay_password
|
||||||
from_secret: docker_password
|
registry: quay.io
|
||||||
repo: plugins/git-action
|
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
||||||
tags: linux-arm
|
username:
|
||||||
username:
|
from_secret: quay_username
|
||||||
from_secret: docker_username
|
when:
|
||||||
when:
|
ref:
|
||||||
event:
|
- refs/heads/main
|
||||||
- pull_request
|
- refs/tags/**
|
||||||
|
depends_on:
|
||||||
- name: publish
|
- dryrun
|
||||||
pull: always
|
|
||||||
image: plugins/docker:linux-arm
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: linux-arm
|
|
||||||
daemon_off: false
|
|
||||||
dockerfile: docker/Dockerfile.linux.arm
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: plugins/git-action
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/main
|
||||||
- "refs/tags/**"
|
- refs/tags/**
|
||||||
- "refs/pull/**"
|
- refs/pull/**
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- testing
|
- test
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: docs
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
limit: 1
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: markdownlint
|
||||||
|
image: thegeeklab/markdownlint-cli
|
||||||
|
commands:
|
||||||
|
- markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md'
|
||||||
|
|
||||||
|
- name: spellcheck
|
||||||
|
image: thegeeklab/alpine-tools
|
||||||
|
commands:
|
||||||
|
- spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions
|
||||||
|
environment:
|
||||||
|
FORCE_COLOR: true
|
||||||
|
NPM_CONFIG_LOGLEVEL: error
|
||||||
|
|
||||||
|
- name: publish
|
||||||
|
image: plugins/gh-pages
|
||||||
|
settings:
|
||||||
|
pages_directory: _docs/
|
||||||
|
password:
|
||||||
|
from_secret: github_token
|
||||||
|
target_branch: docs
|
||||||
|
username:
|
||||||
|
from_secret: github_username
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
ref:
|
||||||
|
- refs/heads/main
|
||||||
|
- refs/tags/**
|
||||||
|
- refs/pull/**
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- build-binaries
|
||||||
|
- build-container-amd64
|
||||||
|
- build-container-arm64
|
||||||
|
- build-container-arm
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
@ -300,33 +374,89 @@ platform:
|
|||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: manifest
|
- name: manifest-dockerhub
|
||||||
pull: always
|
image: plugins/manifest
|
||||||
image: plugins/manifest
|
settings:
|
||||||
settings:
|
auto_tag: true
|
||||||
auto_tag: true
|
ignore_missing: true
|
||||||
ignore_missing: true
|
password:
|
||||||
password:
|
from_secret: docker_password
|
||||||
from_secret: docker_password
|
spec: docker/manifest.tmpl
|
||||||
spec: docker/manifest.tmpl
|
username:
|
||||||
username:
|
from_secret: docker_username
|
||||||
from_secret: docker_username
|
when:
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
|
||||||
- name: microbadger
|
- name: manifest-quay
|
||||||
pull: always
|
image: plugins/manifest
|
||||||
image: plugins/webhook
|
settings:
|
||||||
settings:
|
auto_tag: true
|
||||||
urls:
|
ignore_missing: true
|
||||||
from_secret: microbadger_url
|
password:
|
||||||
|
from_secret: quay_password
|
||||||
|
spec: docker/manifest-quay.tmpl
|
||||||
|
username:
|
||||||
|
from_secret: quay_username
|
||||||
|
when:
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
|
||||||
|
- name: pushrm-dockerhub
|
||||||
|
image: chko/docker-pushrm:1
|
||||||
|
environment:
|
||||||
|
DOCKER_PASS:
|
||||||
|
from_secret: docker_password
|
||||||
|
DOCKER_USER:
|
||||||
|
from_secret: docker_username
|
||||||
|
PUSHRM_FILE: README.md
|
||||||
|
PUSHRM_SHORT: Drone plugin to execute git actions
|
||||||
|
PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
when:
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
|
||||||
|
- name: pushrm-quay
|
||||||
|
image: chko/docker-pushrm:1
|
||||||
|
environment:
|
||||||
|
APIKEY__QUAY_IO:
|
||||||
|
from_secret: quay_token
|
||||||
|
PUSHRM_FILE: README.md
|
||||||
|
PUSHRM_TARGET: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
||||||
|
when:
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
|
||||||
|
- name: matrix
|
||||||
|
image: thegeeklab/drone-matrix
|
||||||
|
settings:
|
||||||
|
homeserver:
|
||||||
|
from_secret: matrix_homeserver
|
||||||
|
password:
|
||||||
|
from_secret: matrix_password
|
||||||
|
roomid:
|
||||||
|
from_secret: matrix_roomid
|
||||||
|
template: "Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}"
|
||||||
|
username:
|
||||||
|
from_secret: matrix_username
|
||||||
|
when:
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
- failure
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/master
|
- refs/heads/main
|
||||||
- "refs/tags/**"
|
- refs/tags/**
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
- failure
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- linux-amd64
|
- docs
|
||||||
- linux-arm64
|
|
||||||
- linux-arm
|
---
|
||||||
|
kind: signature
|
||||||
|
hmac: fa6e3cc79dbe3ac732db2f1949298af295708d6d5932690ed63a8ca74d0eed25
|
||||||
|
|
||||||
...
|
...
|
||||||
|
9
.github/issue_template.md
vendored
9
.github/issue_template.md
vendored
@ -1,9 +0,0 @@
|
|||||||
<!-- PLEASE READ BEFORE DELETING
|
|
||||||
|
|
||||||
Bugs or Issues? Due to the high number of false positive issues we receive,
|
|
||||||
please do not create a GitHub issue until you have discussed and verified
|
|
||||||
with community support at:
|
|
||||||
|
|
||||||
https://discourse.drone.io/
|
|
||||||
|
|
||||||
-->
|
|
0
.github/pull_request_template.md
vendored
0
.github/pull_request_template.md
vendored
51
.github/settings.yml
vendored
51
.github/settings.yml
vendored
@ -1,15 +1,15 @@
|
|||||||
repository:
|
repository:
|
||||||
name: drone-codacy
|
name: drone-git-action
|
||||||
description: Drone plugin to publish coverage to Codacy
|
description: Drone plugin to execute git actions
|
||||||
homepage: http://plugins.drone.io/drone-plugins/drone-codacy
|
homepage: https://drone-plugin-index.geekdocs.de/plugins/drone-git-action
|
||||||
topics: drone, drone-plugin
|
topics: drone, drone-plugin
|
||||||
|
|
||||||
private: false
|
private: false
|
||||||
has_issues: true
|
has_issues: true
|
||||||
has_wiki: false
|
has_wiki: false
|
||||||
has_downloads: false
|
has_downloads: true
|
||||||
|
|
||||||
default_branch: master
|
default_branch: main
|
||||||
|
|
||||||
allow_squash_merge: true
|
allow_squash_merge: true
|
||||||
allow_merge_commit: true
|
allow_merge_commit: true
|
||||||
@ -19,6 +19,9 @@ labels:
|
|||||||
- name: bug
|
- name: bug
|
||||||
color: d73a4a
|
color: d73a4a
|
||||||
description: Something isn't working
|
description: Something isn't working
|
||||||
|
- name: documentation
|
||||||
|
color: 0075ca
|
||||||
|
description: Improvements or additions to documentation
|
||||||
- name: duplicate
|
- name: duplicate
|
||||||
color: cfd3d7
|
color: cfd3d7
|
||||||
description: This issue or pull request already exists
|
description: This issue or pull request already exists
|
||||||
@ -37,37 +40,29 @@ labels:
|
|||||||
- name: question
|
- name: question
|
||||||
color: d876e3
|
color: d876e3
|
||||||
description: Further information is requested
|
description: Further information is requested
|
||||||
- name: renovate
|
|
||||||
color: e99695
|
|
||||||
description: Automated action from Renovate
|
|
||||||
- name: wontfix
|
- name: wontfix
|
||||||
color: ffffff
|
color: ffffff
|
||||||
description: This will not be worked on
|
description: This will not be worked on
|
||||||
|
|
||||||
teams:
|
|
||||||
- name: Admins
|
|
||||||
permission: admin
|
|
||||||
- name: Captain
|
|
||||||
permission: admin
|
|
||||||
- name: Maintainers
|
|
||||||
permission: push
|
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
- name: master
|
- name: main
|
||||||
protection:
|
protection:
|
||||||
required_pull_request_reviews:
|
required_pull_request_reviews: null
|
||||||
required_approving_review_count: 1
|
|
||||||
dismiss_stale_reviews: false
|
|
||||||
require_code_owner_reviews: false
|
|
||||||
dismissal_restrictions:
|
|
||||||
teams:
|
|
||||||
- Admins
|
|
||||||
- Captain
|
|
||||||
required_status_checks:
|
required_status_checks:
|
||||||
strict: true
|
strict: false
|
||||||
contexts:
|
contexts:
|
||||||
- continuous-integration/drone/pr
|
- continuous-integration/drone/pr
|
||||||
enforce_admins: false
|
enforce_admins: true
|
||||||
|
required_linear_history: true
|
||||||
|
restrictions: null
|
||||||
|
- name: docs
|
||||||
|
protection:
|
||||||
|
required_pull_request_reviews: null
|
||||||
|
required_status_checks: null
|
||||||
|
enforce_admins: true
|
||||||
|
required_linear_history: true
|
||||||
restrictions:
|
restrictions:
|
||||||
|
apps: []
|
||||||
users: []
|
users: []
|
||||||
teams: []
|
teams:
|
||||||
|
- bot
|
||||||
|
32
.gitignore
vendored
32
.gitignore
vendored
@ -1,30 +1,6 @@
|
|||||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
/dist/
|
||||||
*.o
|
/release/
|
||||||
*.a
|
/drone-git-action*
|
||||||
*.so
|
|
||||||
|
|
||||||
# Folders
|
|
||||||
_obj
|
|
||||||
_test
|
|
||||||
|
|
||||||
# Architecture specific extensions/prefixes
|
|
||||||
*.[568vq]
|
|
||||||
[568vq].out
|
|
||||||
|
|
||||||
*.cgo1.go
|
|
||||||
*.cgo2.c
|
|
||||||
_cgo_defun.c
|
|
||||||
_cgo_gotypes.go
|
|
||||||
_cgo_export.*
|
|
||||||
|
|
||||||
_testmain.go
|
|
||||||
|
|
||||||
*.exe
|
|
||||||
*.test
|
|
||||||
*.prof
|
|
||||||
|
|
||||||
release/
|
|
||||||
vendor/
|
|
||||||
|
|
||||||
coverage.out
|
coverage.out
|
||||||
drone-git-action
|
CHANGELOG.md
|
||||||
|
31
.golangci.yml
Normal file
31
.golangci.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
linters:
|
||||||
|
enable:
|
||||||
|
- gosimple
|
||||||
|
- deadcode
|
||||||
|
- typecheck
|
||||||
|
- govet
|
||||||
|
- errcheck
|
||||||
|
- staticcheck
|
||||||
|
- unused
|
||||||
|
- structcheck
|
||||||
|
- varcheck
|
||||||
|
- dupl
|
||||||
|
- gofmt
|
||||||
|
- misspell
|
||||||
|
- gocritic
|
||||||
|
- bidichk
|
||||||
|
- ineffassign
|
||||||
|
- revive
|
||||||
|
- gofumpt
|
||||||
|
- depguard
|
||||||
|
enable-all: false
|
||||||
|
disable-all: true
|
||||||
|
fast: false
|
||||||
|
|
||||||
|
run:
|
||||||
|
timeout: 3m
|
||||||
|
|
||||||
|
linters-settings:
|
||||||
|
gofumpt:
|
||||||
|
extra-rules: true
|
||||||
|
lang-version: "1.18"
|
6
.markdownlint.yml
Normal file
6
.markdownlint.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
default: True
|
||||||
|
MD013: False
|
||||||
|
MD041: False
|
||||||
|
MD004:
|
||||||
|
style: dash
|
3
.prettierignore
Normal file
3
.prettierignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.drone.yml
|
||||||
|
*.tpl.md
|
||||||
|
LICENSE
|
31
CONTRIBUTING.md
Normal file
31
CONTRIBUTING.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
## Security
|
||||||
|
|
||||||
|
If you think you have found a **security issue**, please do not mention it in this repository.
|
||||||
|
Instead, send an email to security@thegeeklab.de with as many details as possible so it can be handled confidential.
|
||||||
|
|
||||||
|
## Bug Reports and Feature Requests
|
||||||
|
|
||||||
|
If you have found a **bug** or have a **feature request** please use the search first in case a similar issue already exists.
|
||||||
|
If not, please create an issue in this repository
|
||||||
|
|
||||||
|
## Code
|
||||||
|
|
||||||
|
If you would like to fix a bug or implement a feature, please fork the repository and create a Pull Request.
|
||||||
|
|
||||||
|
Before you start any Pull Request, it is recommended that you create an issue to discuss first if you have any
|
||||||
|
doubts about requirement or implementation. That way you can be sure that the maintainer(s) agree on what to change and how,
|
||||||
|
and you can hopefully get a quick merge afterwards.
|
||||||
|
|
||||||
|
Pull Requests can only be merged once all status checks are green.
|
||||||
|
|
||||||
|
## Do not force push to your Pull Request branch
|
||||||
|
|
||||||
|
Please do not force push to your Pull Requests branch after you have created your Pull Request, as doing so makes it harder for us to review your work.
|
||||||
|
Pull Requests will always be squashed by us when we merge your work. Commit as many times as you need in your Pull Request branch.
|
||||||
|
|
||||||
|
## Re-requesting a review
|
||||||
|
|
||||||
|
Please do not ping your reviewer(s) by mentioning them in a new comment. Instead, use the re-request review functionality.
|
||||||
|
Read more about this in the [GitHub docs, Re-requesting a review](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request#re-requesting-a-review).
|
6
LICENSE
6
LICENSE
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
Apache License
|
Apache License
|
||||||
Version 2.0, January 2004
|
Version 2.0, January 2004
|
||||||
http://www.apache.org/licenses/
|
http://www.apache.org/licenses/
|
||||||
@ -178,7 +179,7 @@
|
|||||||
APPENDIX: How to apply the Apache License to your work.
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
To apply the Apache License to your work, attach the following
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
replaced with your own identifying information. (Don't include
|
replaced with your own identifying information. (Don't include
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
comment syntax for the file format. We also recommend that a
|
comment syntax for the file format. We also recommend that a
|
||||||
@ -186,7 +187,7 @@
|
|||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright {yyyy} {name of copyright owner}
|
Copyright 2022 Robert Kaussow <mail@thegeeklab.de>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -199,4 +200,3 @@
|
|||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
|
96
Makefile
Normal file
96
Makefile
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
# renovate: datasource=github-releases depName=mvdan/gofumpt
|
||||||
|
GOFUMPT_PACKAGE_VERSION := v0.4.0
|
||||||
|
# renovate: datasource=github-releases depName=golangci/golangci-lint
|
||||||
|
GOLANGCI_LINT_PACKAGE_VERSION := v1.50.1
|
||||||
|
|
||||||
|
EXECUTABLE := drone-git-action
|
||||||
|
|
||||||
|
DIST := dist
|
||||||
|
DIST_DIRS := $(DIST)
|
||||||
|
IMPORT := github.com/thegeeklab/$(EXECUTABLE)
|
||||||
|
|
||||||
|
GO ?= go
|
||||||
|
CWD ?= $(shell pwd)
|
||||||
|
PACKAGES ?= $(shell go list ./...)
|
||||||
|
SOURCES ?= $(shell find . -name "*.go" -type f)
|
||||||
|
|
||||||
|
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@$(GOFUMPT_PACKAGE_VERSION)
|
||||||
|
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_PACKAGE_VERSION)
|
||||||
|
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
||||||
|
|
||||||
|
GENERATE ?=
|
||||||
|
XGO_VERSION := go-1.19.x
|
||||||
|
XGO_TARGETS ?= linux/amd64,linux/arm-6,linux/arm-7,linux/arm64
|
||||||
|
|
||||||
|
TAGS ?= netgo
|
||||||
|
|
||||||
|
ifndef VERSION
|
||||||
|
ifneq ($(DRONE_TAG),)
|
||||||
|
VERSION ?= $(subst v,,$(DRONE_TAG))
|
||||||
|
else
|
||||||
|
VERSION ?= $(shell git rev-parse --short HEAD)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef DATE
|
||||||
|
DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%S%z")
|
||||||
|
endif
|
||||||
|
|
||||||
|
LDFLAGS += -s -w -X "main.BuildVersion=$(VERSION)" -X "main.BuildDate=$(DATE)"
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: clean build
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
$(GO) clean -i ./...
|
||||||
|
rm -rf $(DIST_DIRS)
|
||||||
|
|
||||||
|
.PHONY: fmt
|
||||||
|
fmt:
|
||||||
|
$(GO) run $(GOFUMPT_PACKAGE) -extra -w $(SOURCES)
|
||||||
|
|
||||||
|
.PHONY: golangci-lint
|
||||||
|
golangci-lint:
|
||||||
|
$(GO) run $(GOLANGCI_LINT_PACKAGE) run
|
||||||
|
|
||||||
|
.PHONY: lint
|
||||||
|
lint: golangci-lint
|
||||||
|
|
||||||
|
.PHONY: generate
|
||||||
|
generate:
|
||||||
|
$(GO) generate $(GENERATE)
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test:
|
||||||
|
$(GO) test -v -coverprofile coverage.out $(PACKAGES)
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build: $(DIST)/$(EXECUTABLE)
|
||||||
|
|
||||||
|
$(DIST)/$(EXECUTABLE): $(SOURCES)
|
||||||
|
$(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE)
|
||||||
|
|
||||||
|
$(DIST_DIRS):
|
||||||
|
mkdir -p $(DIST_DIRS)
|
||||||
|
|
||||||
|
.PHONY: xgo
|
||||||
|
xgo: | $(DIST_DIRS)
|
||||||
|
$(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -v -ldflags '-extldflags "-static" $(LDFLAGS)' -tags '$(TAGS)' -targets '$(XGO_TARGETS)' -out $(EXECUTABLE) --pkg cmd/$(EXECUTABLE) .
|
||||||
|
cp /build/* $(CWD)/$(DIST)
|
||||||
|
ls -l $(CWD)/$(DIST)
|
||||||
|
|
||||||
|
.PHONY: checksum
|
||||||
|
checksum:
|
||||||
|
cd $(DIST); $(foreach file,$(wildcard $(DIST)/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
|
||||||
|
ls -l $(CWD)/$(DIST)
|
||||||
|
|
||||||
|
.PHONY: release
|
||||||
|
release: xgo checksum
|
||||||
|
|
||||||
|
.PHONY: deps
|
||||||
|
deps:
|
||||||
|
$(GO) mod download
|
||||||
|
$(GO) install $(GOFUMPT_PACKAGE)
|
||||||
|
$(GO) install $(GOLANGCI_LINT_PACKAGE)
|
||||||
|
$(GO) install $(XGO_PACKAGE)
|
49
README.md
49
README.md
@ -1,44 +1,21 @@
|
|||||||
# drone-git-action
|
# drone-git-action
|
||||||
|
|
||||||
[![Build Status](http://cloud.drone.io/api/badges/drone-plugins/drone-git-action/status.svg)](http://cloud.drone.io/drone-plugins/drone-git-action)
|
Drone plugin to execute git actions
|
||||||
[![Gitter chat](https://badges.gitter.im/drone/drone.png)](https://gitter.im/drone/drone)
|
|
||||||
[![Join the discussion at https://discourse.drone.io](https://img.shields.io/badge/discourse-forum-orange.svg)](https://discourse.drone.io)
|
|
||||||
[![Drone questions at https://stackoverflow.com](https://img.shields.io/badge/drone-stackoverflow-orange.svg)](https://stackoverflow.com/questions/tagged/drone.io)
|
|
||||||
[![](https://images.microbadger.com/badges/image/plugins/git-action.svg)](https://microbadger.com/images/plugins/git-action "Get your own image badge on microbadger.com")
|
|
||||||
[![Go Doc](https://godoc.org/github.com/drone-plugins/drone-git-action?status.svg)](http://godoc.org/github.com/drone-plugins/drone-git-action)
|
|
||||||
[![Go Report](https://goreportcard.com/badge/github.com/drone-plugins/drone-git-action)](https://goreportcard.com/report/github.com/drone-plugins/drone-git-action)
|
|
||||||
|
|
||||||
Drone plugin to handle Git actions like `clone`, `commit` and `push`. For the usage information and a listing of the available options please take a look at [the docs](http://plugins.drone.io/drone-plugins/drone-git-action/).
|
[![Build Status](https://img.shields.io/drone/build/thegeeklab/drone-git-action?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/drone-git-action)
|
||||||
|
[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/drone-git-action)
|
||||||
|
[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/drone-git-action)
|
||||||
|
[![Go Report Card](https://goreportcard.com/badge/github.com/thegeeklab/drone-git-action)](https://goreportcard.com/report/github.com/thegeeklab/drone-git-action)
|
||||||
|
[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/drone-git-action)](https://github.com/thegeeklab/drone-git-action/graphs/contributors)
|
||||||
|
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/drone-git-action)
|
||||||
|
[![License: Apache-2.0](https://img.shields.io/github/license/thegeeklab/drone-git-action)](https://github.com/thegeeklab/drone-git-action/blob/main/LICENSE)
|
||||||
|
|
||||||
## Build
|
Drone plugin to execute git actions. You can find the full documentation at [https://drone-plugin-index.geekdocs.de](https://drone-plugin-index.geekdocs.de/plugins/drone-git-action).
|
||||||
|
|
||||||
Build the binary with the following command:
|
## Contributors
|
||||||
|
|
||||||
```console
|
Special thanks to all [contributors](https://github.com/thegeeklab/drone-git-action/graphs/contributors). If you would like to contribute, please see the [instructions](https://github.com/thegeeklab/drone-git-action/blob/main/CONTRIBUTING.md).
|
||||||
export GOOS=linux
|
|
||||||
export GOARCH=amd64
|
|
||||||
export CGO_ENABLED=0
|
|
||||||
export GO111MODULE=on
|
|
||||||
|
|
||||||
go build -v -a -tags netgo -o release/linux/amd64/drone-git-action
|
## License
|
||||||
```
|
|
||||||
|
|
||||||
## Docker
|
This project is licensed under the Apache-2.0 License - see the [LICENSE](https://github.com/thegeeklab/drone-docker/blob/main/LICENSE) file for details.
|
||||||
|
|
||||||
Build the Docker image with the following command:
|
|
||||||
|
|
||||||
```console
|
|
||||||
docker build \
|
|
||||||
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
|
||||||
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
|
|
||||||
--file docker/Dockerfile.linux.amd64 --tag plugins/git-action .
|
|
||||||
```
|
|
||||||
|
|
||||||
### Usage
|
|
||||||
|
|
||||||
```console
|
|
||||||
docker run --rm \
|
|
||||||
-v $(pwd):$(pwd) \
|
|
||||||
-w $(pwd) \
|
|
||||||
plugins/git-action
|
|
||||||
```
|
|
||||||
|
135
cmd/drone-git-action/config.go
Normal file
135
cmd/drone-git-action/config.go
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/thegeeklab/drone-git-action/plugin"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
// settingsFlags has the cli.Flags for the plugin.Settings.
|
||||||
|
func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
||||||
|
return []cli.Flag{
|
||||||
|
&cli.StringSliceFlag{
|
||||||
|
Name: "actions",
|
||||||
|
Usage: "actions to execute",
|
||||||
|
EnvVars: []string{"PLUGIN_ACTIONS"},
|
||||||
|
Destination: &settings.Actions,
|
||||||
|
Required: true,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "commit.author.name",
|
||||||
|
Usage: "git author name",
|
||||||
|
EnvVars: []string{"PLUGIN_AUTHOR_NAME", "DRONE_COMMIT_AUTHOR"},
|
||||||
|
Destination: &settings.Commit.Author.Name,
|
||||||
|
Required: true,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "commit.author.email",
|
||||||
|
Usage: "git author email",
|
||||||
|
EnvVars: []string{"PLUGIN_AUTHOR_EMAIL", "DRONE_COMMIT_AUTHOR_EMAIL"},
|
||||||
|
Destination: &settings.Commit.Author.Email,
|
||||||
|
Required: true,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "netrc.machine",
|
||||||
|
Usage: "netrc machine",
|
||||||
|
EnvVars: []string{"PLUGIN_NETRC_MACHINE", "DRONE_NETRC_MACHINE"},
|
||||||
|
Destination: &settings.Netrc.Machine,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "netrc.username",
|
||||||
|
Usage: "netrc username",
|
||||||
|
EnvVars: []string{"PLUGIN_NETRC_USERNAME", "DRONE_NETRC_USERNAME"},
|
||||||
|
Destination: &settings.Netrc.Login,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "netrc.password",
|
||||||
|
Usage: "netrc password",
|
||||||
|
EnvVars: []string{"PLUGIN_NETRC_PASSWORD", "DRONE_NETRC_PASSWORD"},
|
||||||
|
Destination: &settings.Netrc.Password,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "ssh-key",
|
||||||
|
Usage: "private ssh key",
|
||||||
|
EnvVars: []string{"PLUGIN_SSH_KEY"},
|
||||||
|
Destination: &settings.SSHKey,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "remote",
|
||||||
|
Usage: "url of the repo",
|
||||||
|
EnvVars: []string{"PLUGIN_REMOTE"},
|
||||||
|
Destination: &settings.Remote,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "name of branch",
|
||||||
|
EnvVars: []string{"PLUGIN_BRANCH"},
|
||||||
|
Destination: &settings.Branch,
|
||||||
|
Value: "main",
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "path",
|
||||||
|
Usage: "path to git repo",
|
||||||
|
EnvVars: []string{"PLUGIN_PATH"},
|
||||||
|
Destination: &settings.Path,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "message",
|
||||||
|
Usage: "commit message",
|
||||||
|
EnvVars: []string{"PLUGIN_MESSAGE"},
|
||||||
|
Destination: &settings.Message,
|
||||||
|
Value: "[skip ci] Commit dirty state",
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "force",
|
||||||
|
Usage: "force push to remote",
|
||||||
|
EnvVars: []string{"PLUGIN_FORCE"},
|
||||||
|
Destination: &settings.Force,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "followtags",
|
||||||
|
Usage: "push to remote with tags",
|
||||||
|
EnvVars: []string{"PLUGIN_FOLLOWTAGS"},
|
||||||
|
Destination: &settings.FollowTags,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "skip-verify",
|
||||||
|
Usage: "skip ssl verification",
|
||||||
|
EnvVars: []string{"PLUGIN_SKIP_VERIFY"},
|
||||||
|
Destination: &settings.SkipVerify,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "empty-commit",
|
||||||
|
Usage: "allow empty commits",
|
||||||
|
EnvVars: []string{"PLUGIN_EMPTY_COMMIT"},
|
||||||
|
Destination: &settings.EmptyCommit,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "no-verify",
|
||||||
|
Usage: "bypasses commit hooks",
|
||||||
|
EnvVars: []string{"PLUGIN_NO_VERIFY"},
|
||||||
|
Destination: &settings.NoVerify,
|
||||||
|
Category: category,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
63
cmd/drone-git-action/main.go
Normal file
63
cmd/drone-git-action/main.go
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/joho/godotenv"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/thegeeklab/drone-git-action/plugin"
|
||||||
|
"github.com/thegeeklab/drone-plugin-lib/v2/urfave"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
BuildVersion = "devel"
|
||||||
|
BuildDate = "00000000"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
settings := &plugin.Settings{}
|
||||||
|
|
||||||
|
if _, err := os.Stat("/run/drone/env"); err == nil {
|
||||||
|
_ = godotenv.Overload("/run/drone/env")
|
||||||
|
}
|
||||||
|
|
||||||
|
cli.VersionPrinter = func(c *cli.Context) {
|
||||||
|
fmt.Printf("%s version=%s date=%s\n", c.App.Name, c.App.Version, BuildDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
app := &cli.App{
|
||||||
|
Name: "drone-git-action",
|
||||||
|
Usage: "handle comments to github issues or pull requests",
|
||||||
|
Version: BuildVersion,
|
||||||
|
Flags: append(settingsFlags(settings, urfave.FlagsPluginCategory), urfave.Flags()...),
|
||||||
|
Action: run(settings),
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := app.Run(os.Args); err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func run(settings *plugin.Settings) cli.ActionFunc {
|
||||||
|
return func(ctx *cli.Context) error {
|
||||||
|
urfave.LoggingFromContext(ctx)
|
||||||
|
|
||||||
|
plugin := plugin.New(
|
||||||
|
*settings,
|
||||||
|
urfave.PipelineFromContext(ctx),
|
||||||
|
urfave.NetworkFromContext(ctx),
|
||||||
|
)
|
||||||
|
|
||||||
|
if err := plugin.Validate(); err != nil {
|
||||||
|
return fmt.Errorf("validation failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := plugin.Execute(); err != nil {
|
||||||
|
return fmt.Errorf("execution failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
12
docker/Dockerfile.amd64
Normal file
12
docker/Dockerfile.amd64
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
FROM alpine:3.17@sha256:8914eb54f968791faf6a8638949e480fef81e697984fba772b3976835194c6d4
|
||||||
|
|
||||||
|
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
|
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
|
LABEL org.opencontainers.image.title="drone-git-action"
|
||||||
|
LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-git-action"
|
||||||
|
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-git-action"
|
||||||
|
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-git-action"
|
||||||
|
|
||||||
|
ADD dist/drone-git-action /bin/
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/drone-git-action"]
|
12
docker/Dockerfile.arm
Normal file
12
docker/Dockerfile.arm
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
FROM arm32v7/alpine:3.17@sha256:4c679bd1e6b6516faf8466986fc2a9f52496e61cada7c29ec746621a954a80ac
|
||||||
|
|
||||||
|
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
|
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
|
LABEL org.opencontainers.image.title="drone-git-action"
|
||||||
|
LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-git-action"
|
||||||
|
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-git-action"
|
||||||
|
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-git-action"
|
||||||
|
|
||||||
|
ADD dist/drone-git-action /bin/
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/drone-git-action"]
|
12
docker/Dockerfile.arm64
Normal file
12
docker/Dockerfile.arm64
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
FROM arm64v8/alpine:3.17@sha256:af06af3514c44a964d3b905b498cf6493db8f1cde7c10e078213a89c87308ba0
|
||||||
|
|
||||||
|
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
|
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
|
||||||
|
LABEL org.opencontainers.image.title="drone-git-action"
|
||||||
|
LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-git-action"
|
||||||
|
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-git-action"
|
||||||
|
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-git-action"
|
||||||
|
|
||||||
|
ADD dist/drone-git-action /bin/
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/drone-git-action"]
|
@ -1,11 +0,0 @@
|
|||||||
FROM plugins/base:linux-amd64
|
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
|
|
||||||
org.label-schema.name="Drone Git Action" \
|
|
||||||
org.label-schema.vendor="Drone.IO Community" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
|
||||||
|
|
||||||
ADD release/linux/amd64/drone-git-action /bin/
|
|
||||||
ENTRYPOINT ["/bin/drone-git-action"]
|
|
@ -1,11 +0,0 @@
|
|||||||
FROM plugins/base:linux-arm
|
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
|
|
||||||
org.label-schema.name="Drone Git Action" \
|
|
||||||
org.label-schema.vendor="Drone.IO Community" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
|
||||||
|
|
||||||
ADD release/linux/arm/drone-git-action /bin/
|
|
||||||
ENTRYPOINT ["/bin/drone-git-action"]
|
|
@ -1,11 +0,0 @@
|
|||||||
FROM plugins/base:linux-arm64
|
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
|
|
||||||
org.label-schema.name="Drone Git Action" \
|
|
||||||
org.label-schema.vendor="Drone.IO Community" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
|
||||||
|
|
||||||
ADD release/linux/arm64/drone-git-action /bin/
|
|
||||||
ENTRYPOINT ["/bin/drone-git-action"]
|
|
@ -1,16 +0,0 @@
|
|||||||
# escape=`
|
|
||||||
FROM plugins/base:windows-1803
|
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
|
||||||
org.label-schema.name="Drone Git Action" `
|
|
||||||
org.label-schema.vendor="Drone.IO Community" `
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
RUN Invoke-WebRequest 'https://github.com/git-for-windows/git/releases/download/v2.12.2.windows.2/MinGit-2.12.2.2-64-bit.zip' -OutFile 'git.zip'; `
|
|
||||||
Expand-Archive -Path git.zip -DestinationPath c:\git\ -Force; `
|
|
||||||
$env:PATH = 'c:\git\cmd;c:\git\mingw64\bin;c:\git\usr\bin;{0}' -f $env:PATH; `
|
|
||||||
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH; `
|
|
||||||
Remove-Item -Path git.zip
|
|
||||||
|
|
||||||
ADD release/windows/amd64/drone-git-action.exe C:/bin/drone-git-action.exe
|
|
||||||
ENTRYPOINT [ "C:\\bin\\drone-git-action.exe" ]
|
|
@ -1,16 +0,0 @@
|
|||||||
# escape=`
|
|
||||||
FROM plugins/base:windows-1809
|
|
||||||
|
|
||||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
|
||||||
org.label-schema.name="Drone Git Action" `
|
|
||||||
org.label-schema.vendor="Drone.IO Community" `
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
RUN Invoke-WebRequest 'https://github.com/git-for-windows/git/releases/download/v2.12.2.windows.2/MinGit-2.12.2.2-64-bit.zip' -OutFile 'git.zip'; `
|
|
||||||
Expand-Archive -Path git.zip -DestinationPath c:\git\ -Force; `
|
|
||||||
$env:PATH = 'c:\git\cmd;c:\git\mingw64\bin;c:\git\usr\bin;{0}' -f $env:PATH; `
|
|
||||||
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH; `
|
|
||||||
Remove-Item -Path git.zip
|
|
||||||
|
|
||||||
ADD release/windows/amd64/drone-git-action.exe C:/bin/drone-git-action.exe
|
|
||||||
ENTRYPOINT [ "C:\\bin\\drone-git-action.exe" ]
|
|
24
docker/manifest-quay.tmpl
Normal file
24
docker/manifest-quay.tmpl
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
image: quay.io/thegeeklab/drone-git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||||
|
{{#if build.tags}}
|
||||||
|
tags:
|
||||||
|
{{#each build.tags}}
|
||||||
|
- {{this}}
|
||||||
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
|
manifests:
|
||||||
|
- image: quay.io/thegeeklab/drone-git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64
|
||||||
|
platform:
|
||||||
|
architecture: amd64
|
||||||
|
os: linux
|
||||||
|
|
||||||
|
- image: quay.io/thegeeklab/drone-git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm64
|
||||||
|
platform:
|
||||||
|
architecture: arm64
|
||||||
|
os: linux
|
||||||
|
variant: v8
|
||||||
|
|
||||||
|
- image: quay.io/thegeeklab/drone-git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm
|
||||||
|
platform:
|
||||||
|
architecture: arm
|
||||||
|
os: linux
|
||||||
|
variant: v7
|
@ -1,4 +1,4 @@
|
|||||||
image: plugins/git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
image: thegeeklab/drone-git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||||
{{#if build.tags}}
|
{{#if build.tags}}
|
||||||
tags:
|
tags:
|
||||||
{{#each build.tags}}
|
{{#each build.tags}}
|
||||||
@ -6,32 +6,19 @@ tags:
|
|||||||
{{/each}}
|
{{/each}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
manifests:
|
manifests:
|
||||||
-
|
- image: thegeeklab/drone-git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64
|
||||||
image: plugins/git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: linux
|
os: linux
|
||||||
-
|
|
||||||
image: plugins/git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
- image: thegeeklab/drone-git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm64
|
||||||
platform:
|
platform:
|
||||||
architecture: arm64
|
architecture: arm64
|
||||||
os: linux
|
os: linux
|
||||||
variant: v8
|
variant: v8
|
||||||
-
|
|
||||||
image: plugins/git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
- image: thegeeklab/drone-git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm
|
||||||
platform:
|
platform:
|
||||||
architecture: arm
|
architecture: arm
|
||||||
os: linux
|
os: linux
|
||||||
variant: v7
|
variant: v7
|
||||||
-
|
|
||||||
image: plugins/git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: windows
|
|
||||||
version: 1803
|
|
||||||
-
|
|
||||||
image: plugins/git-action:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: windows
|
|
||||||
version: 1809
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package repo
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultCommitMessage = "[skip ci] Commit dirty state"
|
|
||||||
|
|
||||||
// ForceAdd forces the addition of all dirty files.
|
// ForceAdd forces the addition of all dirty files.
|
||||||
func ForceAdd() *exec.Cmd {
|
func ForceAdd() *exec.Cmd {
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
@ -41,10 +39,6 @@ func TestCleanTree() *exec.Cmd {
|
|||||||
|
|
||||||
// EmptyCommit simply create an empty commit
|
// EmptyCommit simply create an empty commit
|
||||||
func EmptyCommit(msg string, noVerify bool) *exec.Cmd {
|
func EmptyCommit(msg string, noVerify bool) *exec.Cmd {
|
||||||
if msg == "" {
|
|
||||||
msg = defaultCommitMessage
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
"git",
|
"git",
|
||||||
"commit",
|
"commit",
|
||||||
@ -64,10 +58,6 @@ func EmptyCommit(msg string, noVerify bool) *exec.Cmd {
|
|||||||
|
|
||||||
// ForceCommit commits every change while skipping CI.
|
// ForceCommit commits every change while skipping CI.
|
||||||
func ForceCommit(msg string, noVerify bool) *exec.Cmd {
|
func ForceCommit(msg string, noVerify bool) *exec.Cmd {
|
||||||
if msg == "" {
|
|
||||||
msg = defaultCommitMessage
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
"git",
|
"git",
|
||||||
"commit",
|
"commit",
|
@ -1,4 +1,4 @@
|
|||||||
package repo
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os/exec"
|
"os/exec"
|
@ -1,4 +1,4 @@
|
|||||||
package repo
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -28,12 +28,12 @@ func RemoteAdd(name, url string) *exec.Cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemotePush pushs the changes from the local head to a remote branch..
|
// RemotePush pushs the changes from the local head to a remote branch..
|
||||||
func RemotePush(remote, branch string, force bool, followtags bool) *exec.Cmd {
|
func RemotePush(remote, branch string, force, followtags bool) *exec.Cmd {
|
||||||
return RemotePushNamedBranch(remote, "HEAD", branch, force, followtags)
|
return RemotePushNamedBranch(remote, "HEAD", branch, force, followtags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemotePushNamedBranch puchs changes from a local to a remote branch.
|
// RemotePushNamedBranch puchs changes from a local to a remote branch.
|
||||||
func RemotePushNamedBranch(remote, localbranch string, branch string, force bool, followtags bool) *exec.Cmd {
|
func RemotePushNamedBranch(remote, localbranch, branch string, force, followtags bool) *exec.Cmd {
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
"git",
|
"git",
|
||||||
"push",
|
"push",
|
@ -1,8 +1,7 @@
|
|||||||
package repo
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -20,12 +19,8 @@ StrictHostKeyChecking no
|
|||||||
UserKnownHostsFile=/dev/null
|
UserKnownHostsFile=/dev/null
|
||||||
`
|
`
|
||||||
|
|
||||||
// WriteKey writes the private key.
|
// WriteKey writes the SSH private key.
|
||||||
func WriteKey(privateKey string) error {
|
func WriteSSHKey(privateKey string) error {
|
||||||
if privateKey == "" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
home := "/root"
|
home := "/root"
|
||||||
|
|
||||||
if currentUser, err := user.Current(); err == nil {
|
if currentUser, err := user.Current(); err == nil {
|
||||||
@ -36,7 +31,7 @@ func WriteKey(privateKey string) error {
|
|||||||
home,
|
home,
|
||||||
".ssh")
|
".ssh")
|
||||||
|
|
||||||
if err := os.MkdirAll(sshpath, 0700); err != nil {
|
if err := os.MkdirAll(sshpath, 0o700); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,10 +39,10 @@ func WriteKey(privateKey string) error {
|
|||||||
sshpath,
|
sshpath,
|
||||||
"config")
|
"config")
|
||||||
|
|
||||||
if err := ioutil.WriteFile(
|
if err := os.WriteFile(
|
||||||
confpath,
|
confpath,
|
||||||
[]byte(configFile),
|
[]byte(configFile),
|
||||||
0700,
|
0o700,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -57,10 +52,10 @@ func WriteKey(privateKey string) error {
|
|||||||
"id_rsa",
|
"id_rsa",
|
||||||
)
|
)
|
||||||
|
|
||||||
if err := ioutil.WriteFile(
|
if err := os.WriteFile(
|
||||||
privpath,
|
privpath,
|
||||||
[]byte(privateKey),
|
[]byte(privateKey),
|
||||||
0600,
|
0o600,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -92,9 +87,9 @@ func WriteNetrc(machine, login, password string) error {
|
|||||||
".netrc",
|
".netrc",
|
||||||
)
|
)
|
||||||
|
|
||||||
return ioutil.WriteFile(
|
return os.WriteFile(
|
||||||
netpath,
|
netpath,
|
||||||
[]byte(netrcContent),
|
[]byte(netrcContent),
|
||||||
0600,
|
0o600,
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package repo
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os/exec"
|
"os/exec"
|
18
go.mod
18
go.mod
@ -1,5 +1,17 @@
|
|||||||
module github.com/drone-plugins/drone-git-action
|
module github.com/thegeeklab/drone-git-action
|
||||||
|
|
||||||
go 1.12
|
go 1.19
|
||||||
|
|
||||||
require github.com/urfave/cli v1.20.0
|
require (
|
||||||
|
github.com/joho/godotenv v1.4.0
|
||||||
|
github.com/sirupsen/logrus v1.9.0
|
||||||
|
github.com/thegeeklab/drone-plugin-lib/v2 v2.2.0
|
||||||
|
github.com/urfave/cli/v2 v2.23.5
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||||
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||||
|
)
|
||||||
|
29
go.sum
29
go.sum
@ -1,2 +1,27 @@
|
|||||||
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
|
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
||||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
|
||||||
|
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||||
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||||
|
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/thegeeklab/drone-plugin-lib/v2 v2.2.0 h1:/rDyNZiR5GFbBLzEL5yges931H6lFmwX302kraFweBU=
|
||||||
|
github.com/thegeeklab/drone-plugin-lib/v2 v2.2.0/go.mod h1:/jLeBCFQRRyO/UFpU3cyx1Pt4fD20ejegmW4PioCSLo=
|
||||||
|
github.com/urfave/cli/v2 v2.23.5 h1:xbrU7tAYviSpqeR3X4nEFWUdB/uDZ6DE+HxmRU7Xtyw=
|
||||||
|
github.com/urfave/cli/v2 v2.23.5/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
|
||||||
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||||
|
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||||
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||||
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
144
main.go
144
main.go
@ -1,144 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/urfave/cli"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
version = "unknown"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
app := cli.NewApp()
|
|
||||||
app.Name = "git-action plugin"
|
|
||||||
app.Usage = "git-action plugin"
|
|
||||||
app.Action = run
|
|
||||||
app.Version = version
|
|
||||||
app.Flags = []cli.Flag{
|
|
||||||
cli.StringSliceFlag{
|
|
||||||
Name: "actions",
|
|
||||||
Usage: "actions to execute",
|
|
||||||
EnvVar: "PLUGIN_ACTIONS",
|
|
||||||
},
|
|
||||||
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "commit.author.name",
|
|
||||||
Usage: "git author name",
|
|
||||||
EnvVar: "PLUGIN_AUTHOR_NAME,DRONE_COMMIT_AUTHOR",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "commit.author.email",
|
|
||||||
Usage: "git author email",
|
|
||||||
EnvVar: "PLUGIN_AUTHOR_EMAIL,DRONE_COMMIT_AUTHOR_EMAIL",
|
|
||||||
},
|
|
||||||
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "netrc.machine",
|
|
||||||
Usage: "netrc machine",
|
|
||||||
EnvVar: "PLUGIN_NETRC_MACHINE,DRONE_NETRC_MACHINE",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "netrc.username",
|
|
||||||
Usage: "netrc username",
|
|
||||||
EnvVar: "PLUGIN_NETRC_USERNAME,DRONE_NETRC_USERNAME",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "netrc.password",
|
|
||||||
Usage: "netrc password",
|
|
||||||
EnvVar: "PLUGIN_NETRC_PASSWORD,DRONE_NETRC_PASSWORD",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "ssh-key",
|
|
||||||
Usage: "private ssh key",
|
|
||||||
EnvVar: "PLUGIN_SSH_KEY",
|
|
||||||
},
|
|
||||||
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "remote",
|
|
||||||
Usage: "url of the repo",
|
|
||||||
EnvVar: "PLUGIN_REMOTE",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "branch",
|
|
||||||
Usage: "name of branch",
|
|
||||||
EnvVar: "PLUGIN_BRANCH",
|
|
||||||
Value: "master",
|
|
||||||
},
|
|
||||||
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "path",
|
|
||||||
Usage: "path to git repo",
|
|
||||||
EnvVar: "PLUGIN_PATH",
|
|
||||||
},
|
|
||||||
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "message",
|
|
||||||
Usage: "commit message",
|
|
||||||
EnvVar: "PLUGIN_MESSAGE",
|
|
||||||
},
|
|
||||||
|
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "force",
|
|
||||||
Usage: "force push to remote",
|
|
||||||
EnvVar: "PLUGIN_FORCE",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "followtags",
|
|
||||||
Usage: "push to remote with tags",
|
|
||||||
EnvVar: "PLUGIN_FOLLOWTAGS",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "skip-verify",
|
|
||||||
Usage: "skip ssl verification",
|
|
||||||
EnvVar: "PLUGIN_SKIP_VERIFY",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "empty-commit",
|
|
||||||
Usage: "allow empty commits",
|
|
||||||
EnvVar: "PLUGIN_EMPTY_COMMIT",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "no-verify",
|
|
||||||
Usage: "bypasses commit hooks",
|
|
||||||
EnvVar: "PLUGIN_NO_VERIFY",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func run(c *cli.Context) error {
|
|
||||||
plugin := Plugin{
|
|
||||||
Netrc: Netrc{
|
|
||||||
Login: c.String("netrc.username"),
|
|
||||||
Machine: c.String("netrc.machine"),
|
|
||||||
Password: c.String("netrc.password"),
|
|
||||||
},
|
|
||||||
Commit: Commit{
|
|
||||||
Author: Author{
|
|
||||||
Name: c.String("commit.author.name"),
|
|
||||||
Email: c.String("commit.author.email"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Config: Config{
|
|
||||||
Actions: c.StringSlice("actions"),
|
|
||||||
Key: c.String("ssh-key"),
|
|
||||||
Remote: c.String("remote"),
|
|
||||||
Branch: c.String("branch"),
|
|
||||||
Path: c.String("path"),
|
|
||||||
Message: c.String("message"),
|
|
||||||
Force: c.Bool("force"),
|
|
||||||
FollowTags: c.Bool("followtags"),
|
|
||||||
SkipVerify: c.Bool("skip-verify"),
|
|
||||||
EmptyCommit: c.Bool("empty-commit"),
|
|
||||||
NoVerify: c.Bool("no-verify"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return plugin.Exec()
|
|
||||||
}
|
|
@ -1,205 +0,0 @@
|
|||||||
local windows_pipe = '\\\\\\\\.\\\\pipe\\\\docker_engine';
|
|
||||||
local windows_pipe_volume = 'docker_pipe';
|
|
||||||
local test_pipeline_name = 'testing';
|
|
||||||
|
|
||||||
local windows(os) = os == 'windows';
|
|
||||||
|
|
||||||
local golang_image(os, version) =
|
|
||||||
'golang:' + '1.11' + if windows(os) then '-windowsservercore-' + version else '';
|
|
||||||
|
|
||||||
{
|
|
||||||
test(os='linux', arch='amd64', version='')::
|
|
||||||
local is_windows = windows(os);
|
|
||||||
local golang = golang_image(os, version);
|
|
||||||
local volumes = if is_windows then [{name: 'gopath', path: 'C:\\\\gopath'}] else [{name: 'gopath', path: '/go',}];
|
|
||||||
{
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: test_pipeline_name,
|
|
||||||
platform: {
|
|
||||||
os: os,
|
|
||||||
arch: arch,
|
|
||||||
version: if std.length(version) > 0 then version,
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
name: 'vet',
|
|
||||||
image: golang,
|
|
||||||
pull: 'always',
|
|
||||||
environment: {
|
|
||||||
GO111MODULE: 'on',
|
|
||||||
},
|
|
||||||
commands: [
|
|
||||||
'go vet ./...',
|
|
||||||
],
|
|
||||||
volumes: volumes,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'test',
|
|
||||||
image: golang,
|
|
||||||
pull: 'always',
|
|
||||||
environment: {
|
|
||||||
GO111MODULE: 'on',
|
|
||||||
},
|
|
||||||
commands: [
|
|
||||||
'go test -cover ./...',
|
|
||||||
],
|
|
||||||
volumes: volumes,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
trigger: {
|
|
||||||
ref: [
|
|
||||||
'refs/heads/master',
|
|
||||||
'refs/tags/**',
|
|
||||||
'refs/pull/**',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
volumes: [{name: 'gopath', temp: {}}]
|
|
||||||
},
|
|
||||||
|
|
||||||
build(name, os='linux', arch='amd64', version='')::
|
|
||||||
local is_windows = windows(os);
|
|
||||||
local tag = if is_windows then os + '-' + version else os + '-' + arch;
|
|
||||||
local file_suffix = std.strReplace(tag, '-', '.');
|
|
||||||
local volumes = if is_windows then [{ name: windows_pipe_volume, path: windows_pipe }] else [];
|
|
||||||
local golang = golang_image(os, version);
|
|
||||||
local plugin_repo = 'plugins/' + std.splitLimit(name, '-', 1)[1];
|
|
||||||
local extension = if is_windows then '.exe' else '';
|
|
||||||
{
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: tag,
|
|
||||||
platform: {
|
|
||||||
os: os,
|
|
||||||
arch: arch,
|
|
||||||
version: if std.length(version) > 0 then version,
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
name: 'build-push',
|
|
||||||
image: golang,
|
|
||||||
pull: 'always',
|
|
||||||
environment: {
|
|
||||||
CGO_ENABLED: '0',
|
|
||||||
GO111MODULE: 'on',
|
|
||||||
},
|
|
||||||
commands: [
|
|
||||||
'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/' + os + '/' + arch + '/' + name + extension,
|
|
||||||
],
|
|
||||||
when: {
|
|
||||||
event: {
|
|
||||||
exclude: ['tag'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'build-tag',
|
|
||||||
image: golang,
|
|
||||||
pull: 'always',
|
|
||||||
environment: {
|
|
||||||
CGO_ENABLED: '0',
|
|
||||||
GO111MODULE: 'on',
|
|
||||||
},
|
|
||||||
commands: [
|
|
||||||
'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/' + os + '/' + arch + '/' + name + extension,
|
|
||||||
],
|
|
||||||
when: {
|
|
||||||
event: ['tag'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'executable',
|
|
||||||
image: golang,
|
|
||||||
pull: 'always',
|
|
||||||
commands: [
|
|
||||||
'./release/' + os + '/' + arch + '/' + name + extension + ' --help',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'dryrun',
|
|
||||||
image: 'plugins/docker:' + tag,
|
|
||||||
pull: 'always',
|
|
||||||
settings: {
|
|
||||||
dry_run: true,
|
|
||||||
tags: tag,
|
|
||||||
dockerfile: 'docker/Dockerfile.' + file_suffix,
|
|
||||||
daemon_off: if is_windows then 'true' else 'false',
|
|
||||||
repo: plugin_repo,
|
|
||||||
username: { from_secret: 'docker_username' },
|
|
||||||
password: { from_secret: 'docker_password' },
|
|
||||||
},
|
|
||||||
volumes: if std.length(volumes) > 0 then volumes,
|
|
||||||
when: {
|
|
||||||
event: ['pull_request'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'publish',
|
|
||||||
image: 'plugins/docker:' + tag,
|
|
||||||
pull: 'always',
|
|
||||||
settings: {
|
|
||||||
auto_tag: true,
|
|
||||||
auto_tag_suffix: tag,
|
|
||||||
daemon_off: if is_windows then 'true' else 'false',
|
|
||||||
dockerfile: 'docker/Dockerfile.' + file_suffix,
|
|
||||||
repo: plugin_repo,
|
|
||||||
username: { from_secret: 'docker_username' },
|
|
||||||
password: { from_secret: 'docker_password' },
|
|
||||||
},
|
|
||||||
volumes: if std.length(volumes) > 0 then volumes,
|
|
||||||
when: {
|
|
||||||
event: {
|
|
||||||
exclude: ['pull_request'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
trigger: {
|
|
||||||
ref: [
|
|
||||||
'refs/heads/master',
|
|
||||||
'refs/tags/**',
|
|
||||||
'refs/pull/**',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
depends_on: [test_pipeline_name],
|
|
||||||
volumes: if is_windows then [{ name: windows_pipe_volume, host: { path: windows_pipe } }],
|
|
||||||
},
|
|
||||||
|
|
||||||
notifications(os='linux', arch='amd64', version='', depends_on=[])::
|
|
||||||
{
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: 'notifications',
|
|
||||||
platform: {
|
|
||||||
os: os,
|
|
||||||
arch: arch,
|
|
||||||
version: if std.length(version) > 0 then version,
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
name: 'manifest',
|
|
||||||
image: 'plugins/manifest',
|
|
||||||
pull: 'always',
|
|
||||||
settings: {
|
|
||||||
username: { from_secret: 'docker_username' },
|
|
||||||
password: { from_secret: 'docker_password' },
|
|
||||||
spec: 'docker/manifest.tmpl',
|
|
||||||
ignore_missing: true,
|
|
||||||
auto_tag: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'microbadger',
|
|
||||||
image: 'plugins/webhook',
|
|
||||||
pull: 'always',
|
|
||||||
settings: {
|
|
||||||
urls: { from_secret: 'microbadger_url' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
trigger: {
|
|
||||||
ref: [
|
|
||||||
'refs/heads/master',
|
|
||||||
'refs/tags/**',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
depends_on: depends_on,
|
|
||||||
},
|
|
||||||
}
|
|
223
plugin.go
223
plugin.go
@ -1,223 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"github.com/drone-plugins/drone-git-action/repo"
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
Netrc struct {
|
|
||||||
Machine string
|
|
||||||
Login string
|
|
||||||
Password string
|
|
||||||
}
|
|
||||||
|
|
||||||
Commit struct {
|
|
||||||
Author Author
|
|
||||||
}
|
|
||||||
|
|
||||||
Author struct {
|
|
||||||
Name string
|
|
||||||
Email string
|
|
||||||
}
|
|
||||||
|
|
||||||
Config struct {
|
|
||||||
Actions []string
|
|
||||||
Key string
|
|
||||||
Remote string
|
|
||||||
Branch string
|
|
||||||
Path string
|
|
||||||
Message string
|
|
||||||
Force bool
|
|
||||||
FollowTags bool
|
|
||||||
SkipVerify bool
|
|
||||||
EmptyCommit bool
|
|
||||||
NoVerify bool
|
|
||||||
}
|
|
||||||
|
|
||||||
Plugin struct {
|
|
||||||
Netrc Netrc
|
|
||||||
Commit Commit
|
|
||||||
Config Config
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func (p *Plugin) Exec() error {
|
|
||||||
if err := p.HandlePath(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := p.WriteConfig(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := p.WriteKey(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := p.WriteNetrc(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, action := range p.Config.Actions {
|
|
||||||
switch action {
|
|
||||||
case "clone":
|
|
||||||
if err := p.InitRepo(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := p.AddRemote(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := p.FetchSource(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := p.CheckoutHead(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
case "commit":
|
|
||||||
if err := p.HandleCommit(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
case "push":
|
|
||||||
if err := p.HandlePush(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("Unknown action %s", action)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// HandlePath changes to a different directory if required
|
|
||||||
func (p Plugin) HandlePath() error {
|
|
||||||
if p.Config.Path != "" {
|
|
||||||
if err := os.MkdirAll(p.Config.Path, os.ModePerm); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := os.Chdir(p.Config.Path); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// WriteConfig writes all required configurations.
|
|
||||||
func (p Plugin) WriteConfig() error {
|
|
||||||
if err := repo.GlobalName(p.Commit.Author.Name).Run(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := repo.GlobalUser(p.Commit.Author.Email).Run(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.Config.SkipVerify {
|
|
||||||
if err := repo.SkipVerify().Run(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// WriteKey writes the private SSH key.
|
|
||||||
func (p Plugin) WriteKey() error {
|
|
||||||
return repo.WriteKey(
|
|
||||||
p.Config.Key,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WriteNetrc writes the netrc config.
|
|
||||||
func (p Plugin) WriteNetrc() error {
|
|
||||||
return repo.WriteNetrc(
|
|
||||||
p.Netrc.Machine,
|
|
||||||
p.Netrc.Login,
|
|
||||||
p.Netrc.Password,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitRepo initializes the repository.
|
|
||||||
func (p Plugin) InitRepo() error {
|
|
||||||
if isDirEmpty(filepath.Join(p.Config.Path, ".git")) {
|
|
||||||
return execute(exec.Command(
|
|
||||||
"git",
|
|
||||||
"init",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddRemote adds a remote to repository.
|
|
||||||
func (p Plugin) AddRemote() error {
|
|
||||||
if p.Config.Remote != "" {
|
|
||||||
if err := execute(repo.RemoteAdd("origin", p.Config.Remote)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// FetchSource fetches the source from remote.
|
|
||||||
func (p Plugin) FetchSource() error {
|
|
||||||
return execute(exec.Command(
|
|
||||||
"git",
|
|
||||||
"fetch",
|
|
||||||
"origin",
|
|
||||||
fmt.Sprintf("+%s:", p.Config.Branch),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckoutHead handles branch checkout.
|
|
||||||
func (p Plugin) CheckoutHead() error {
|
|
||||||
return execute(exec.Command(
|
|
||||||
"git",
|
|
||||||
"checkout",
|
|
||||||
"-qf",
|
|
||||||
"FETCH_HEAD",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
// HandleCommit commits changes locally.
|
|
||||||
func (p Plugin) HandleCommit() error {
|
|
||||||
if err := execute(repo.Add()); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := execute(repo.TestCleanTree()); err != nil {
|
|
||||||
if err := execute(repo.ForceCommit(p.Config.Message, p.Config.NoVerify)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if p.Config.EmptyCommit {
|
|
||||||
if err := execute(repo.EmptyCommit(p.Config.Message, p.Config.NoVerify)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// HandlePush pushs changes to remote.
|
|
||||||
func (p Plugin) HandlePush() error {
|
|
||||||
return execute(repo.RemotePushNamedBranch(
|
|
||||||
"origin",
|
|
||||||
p.Config.Branch,
|
|
||||||
p.Config.Branch,
|
|
||||||
p.Config.Force,
|
|
||||||
p.Config.FollowTags,
|
|
||||||
))
|
|
||||||
}
|
|
105
plugin/git.go
Normal file
105
plugin/git.go
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
package plugin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/thegeeklab/drone-git-action/git"
|
||||||
|
)
|
||||||
|
|
||||||
|
// InitRepo initializes the repository.
|
||||||
|
func (p Plugin) initRepo() error {
|
||||||
|
if isDirEmpty(filepath.Join(p.settings.Path, ".git")) {
|
||||||
|
return execute(exec.Command(
|
||||||
|
"git",
|
||||||
|
"init",
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRemote adds a remote to repository.
|
||||||
|
func (p Plugin) addRemote() error {
|
||||||
|
if p.settings.Remote != "" {
|
||||||
|
if err := execute(git.RemoteAdd("origin", p.settings.Remote)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FetchSource fetches the source from remote.
|
||||||
|
func (p Plugin) fetchSource() error {
|
||||||
|
return execute(exec.Command(
|
||||||
|
"git",
|
||||||
|
"fetch",
|
||||||
|
"origin",
|
||||||
|
fmt.Sprintf("+%s:", p.settings.Branch),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckoutHead handles branch checkout.
|
||||||
|
func (p Plugin) checkoutHead() error {
|
||||||
|
return execute(exec.Command(
|
||||||
|
"git",
|
||||||
|
"checkout",
|
||||||
|
"-qf",
|
||||||
|
p.settings.Branch,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandleClone clones remote.
|
||||||
|
func (p Plugin) handleClone() error {
|
||||||
|
if err := p.initRepo(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := p.addRemote(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := p.fetchSource(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := p.checkoutHead(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandleCommit commits changes locally.
|
||||||
|
func (p Plugin) handleCommit() error {
|
||||||
|
if err := execute(git.Add()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := execute(git.TestCleanTree()); err != nil {
|
||||||
|
if err := execute(git.ForceCommit(p.settings.Message, p.settings.NoVerify)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if p.settings.EmptyCommit {
|
||||||
|
if err := execute(git.EmptyCommit(p.settings.Message, p.settings.NoVerify)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandlePush pushs changes to remote.
|
||||||
|
func (p Plugin) handlePush() error {
|
||||||
|
return execute(git.RemotePushNamedBranch(
|
||||||
|
"origin",
|
||||||
|
p.settings.Branch,
|
||||||
|
p.settings.Branch,
|
||||||
|
p.settings.Force,
|
||||||
|
p.settings.FollowTags,
|
||||||
|
))
|
||||||
|
}
|
110
plugin/impl.go
Normal file
110
plugin/impl.go
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
package plugin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/thegeeklab/drone-git-action/git"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Netrc struct {
|
||||||
|
Machine string
|
||||||
|
Login string
|
||||||
|
Password string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Commit struct {
|
||||||
|
Author Author
|
||||||
|
}
|
||||||
|
|
||||||
|
type Author struct {
|
||||||
|
Name string
|
||||||
|
Email string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Settings for the Plugin.
|
||||||
|
type Settings struct {
|
||||||
|
Actions cli.StringSlice
|
||||||
|
SSHKey string
|
||||||
|
Remote string
|
||||||
|
Branch string
|
||||||
|
Path string
|
||||||
|
Message string
|
||||||
|
Force bool
|
||||||
|
FollowTags bool
|
||||||
|
SkipVerify bool
|
||||||
|
EmptyCommit bool
|
||||||
|
NoVerify bool
|
||||||
|
|
||||||
|
Netrc Netrc
|
||||||
|
Commit Commit
|
||||||
|
Author Author
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate handles the settings validation of the plugin.
|
||||||
|
func (p *Plugin) Validate() error {
|
||||||
|
if (p.settings.SSHKey == "") && (p.settings.Netrc.Login == "" || p.settings.Netrc.Password == "") {
|
||||||
|
return fmt.Errorf("either SSH key or netrc username and password are required")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute provides the implementation of the plugin.
|
||||||
|
func (p *Plugin) Execute() error {
|
||||||
|
if p.settings.Path != "" {
|
||||||
|
if err := os.MkdirAll(p.settings.Path, os.ModePerm); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.Chdir(p.settings.Path); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := git.GlobalName(p.settings.Commit.Author.Name).Run(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := git.GlobalUser(p.settings.Commit.Author.Email).Run(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.settings.SkipVerify {
|
||||||
|
if err := git.SkipVerify().Run(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.settings.SSHKey != "" {
|
||||||
|
if err := git.WriteSSHKey(p.settings.SSHKey); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := git.WriteNetrc(p.settings.Netrc.Machine, p.settings.Netrc.Login, p.settings.Netrc.Password); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, action := range p.settings.Actions.Value() {
|
||||||
|
switch action {
|
||||||
|
case "clone":
|
||||||
|
if err := p.handleClone(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case "commit":
|
||||||
|
if err := p.handleCommit(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case "push":
|
||||||
|
if err := p.handlePush(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unknown action %s", action)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
21
plugin/plugin.go
Normal file
21
plugin/plugin.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package plugin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/thegeeklab/drone-plugin-lib/v2/drone"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Plugin implements drone.Plugin to provide the plugin implementation.
|
||||||
|
type Plugin struct {
|
||||||
|
settings Settings
|
||||||
|
pipeline drone.Pipeline
|
||||||
|
network drone.Network
|
||||||
|
}
|
||||||
|
|
||||||
|
// New initializes a plugin from the given Settings, Pipeline, and Network.
|
||||||
|
func New(settings Settings, pipeline drone.Pipeline, network drone.Network) drone.Plugin {
|
||||||
|
return &Plugin{
|
||||||
|
settings: settings,
|
||||||
|
pipeline: pipeline,
|
||||||
|
network: network,
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package main
|
package plugin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -22,7 +22,6 @@ func execute(cmd *exec.Cmd) error {
|
|||||||
// helper function returns true if directory dir is empty.
|
// helper function returns true if directory dir is empty.
|
||||||
func isDirEmpty(dir string) bool {
|
func isDirEmpty(dir string) bool {
|
||||||
f, err := os.Open(dir)
|
f, err := os.Open(dir)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
4
renovate.json
Normal file
4
renovate.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": ["github>thegeeklab/renovate-presets:golang"]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user