You've already forked git-docker
Compare commits
61 Commits
487521c8bc
...
1.4.0
Author | SHA1 | Date | |
---|---|---|---|
9eec475232
|
|||
a07437cc98
|
|||
8927f0af51
|
|||
947d678377
|
|||
6f725261ff | |||
4a67b7dd55
|
|||
1cb03cd85b
|
|||
5fb3b990f6
|
|||
a9c5450c23
|
|||
4acab0b15c
|
|||
7b005b3fd3
|
|||
8335dc33de
|
|||
8238daf5c8
|
|||
47a919c4ce
|
|||
4e57620e6e
|
|||
df1f74c95c
|
|||
af20703e78
|
|||
cba27052c8
|
|||
50cc76bebf
|
|||
26ebfdf2a7
|
|||
3ffb466310
|
|||
6edca6cdc4
|
|||
b224063b61
|
|||
73ed7b7f29 | |||
7bdd385c82 | |||
3942020271 | |||
0d6f93216e | |||
dddaaa2226 | |||
dd7dbf0c0a | |||
8ce3dffaf3 | |||
5eb189d052 | |||
72270dc9e1 | |||
aa2d41f46b | |||
9c342cdc4f | |||
1916138eca
|
|||
f0e125757b | |||
8fe3458257 | |||
ebfa105e26
|
|||
b9cd56f49d
|
|||
f3c90af2b7
|
|||
213960abc3
|
|||
e5254617f6
|
|||
570825bcaa
|
|||
9fae1f4211
|
|||
8e901429a3
|
|||
db6bbad75b
|
|||
2ca1f86ec4
|
|||
c33efa3ce9
|
|||
d320981914
|
|||
4d91bb9897
|
|||
d6adb0e2e3
|
|||
39d233b3d9 | |||
d2b4c922fd | |||
c40d9ffccc | |||
f03006262c | |||
8070857203 | |||
3ccd78325a | |||
806bc25846 | |||
3d2cbbe9ba | |||
f7b49aaf9e | |||
be769618aa |
@ -1,7 +0,0 @@
|
||||
.github
|
||||
.gitignore
|
||||
.drone.yml
|
||||
LICENSE
|
||||
README.md
|
||||
*/fixtures*
|
||||
*.go
|
||||
|
130
.drone.starlark
130
.drone.starlark
@ -1,130 +0,0 @@
|
||||
# this starlark script should be used to generate the .drone.yml
|
||||
# configuration file.
|
||||
|
||||
def main(ctx):
|
||||
# TODO consider running unit tests before building and
|
||||
# publishing docker images.
|
||||
before = {}
|
||||
|
||||
stages = [
|
||||
linux('arm'),
|
||||
linux('arm64'),
|
||||
linux('amd64'),
|
||||
windows('1903'),
|
||||
windows('1809'),
|
||||
]
|
||||
|
||||
after = manifest()
|
||||
|
||||
# the after stage should only execute after all previous
|
||||
# stages complete. this builds the dependency graph.
|
||||
for stage in stages:
|
||||
after['depends_on'].append(stage['name'])
|
||||
|
||||
return stages + [ after ]
|
||||
|
||||
# create a pipeline stage responsible for building and
|
||||
# publishing the Docker image on linux.
|
||||
def linux(arch):
|
||||
return {
|
||||
'kind': 'pipeline',
|
||||
'type': 'docker',
|
||||
'name': 'linux-%s' % arch,
|
||||
'platform': {
|
||||
'os': 'linux',
|
||||
'arch': arch,
|
||||
},
|
||||
'steps': [
|
||||
{
|
||||
'name': 'build',
|
||||
'image': 'golang:1.10',
|
||||
'commands': [
|
||||
'cd posix',
|
||||
'tar -xf fixtures.tar -C /',
|
||||
'go test -v',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'publish',
|
||||
'image': 'plugins/docker',
|
||||
'settings': {
|
||||
'auto_tag': 'true',
|
||||
'auto_tag_suffix': 'linux-%s' % arch,
|
||||
'dockerfile': 'docker/Dockerfile.linux.%s' % arch,
|
||||
'password': {
|
||||
'from_secret': 'docker_password',
|
||||
},
|
||||
'repo': 'drone/git',
|
||||
'username': 'drone',
|
||||
},
|
||||
'when': {
|
||||
'event': ['push', 'tag']
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
# create a pipeline stage responsible for building and
|
||||
# publishing the Docker image on windows. The windows stage
|
||||
# uses an ssh runner, as opposed to a docker runner.
|
||||
def windows(version):
|
||||
return {
|
||||
'kind': 'pipeline',
|
||||
'type': 'ssh',
|
||||
'name': 'windows-%s-amd64' % version,
|
||||
'platform': {
|
||||
'os': 'windows'
|
||||
},
|
||||
'server': {
|
||||
'host': { 'from_secret': 'windows_server_%s' % version },
|
||||
'user': { 'from_secret': 'windows_username' },
|
||||
'password': { 'from_secret': 'windows_password' },
|
||||
},
|
||||
'steps': [
|
||||
{
|
||||
'name': 'build',
|
||||
'environment': {
|
||||
'USERNAME': { 'from_secret': 'docker_username' },
|
||||
'PASSWORD': { 'from_secret': 'docker_password' },
|
||||
},
|
||||
# TODO these commands build and publish the latest
|
||||
# docker tag regardless of git tag.
|
||||
'commands': [
|
||||
'docker login -u $env:USERNAME -p $env:PASSWORD',
|
||||
'docker build -f docker/Dockerfile.windows.%s -t drone/git:windows-%s-amd64 .' % (version, version),
|
||||
'docker push drone/git:windows-%s-amd64' % version,
|
||||
],
|
||||
},
|
||||
],
|
||||
'trigger': {
|
||||
'event': ['push']
|
||||
}
|
||||
}
|
||||
|
||||
# create a pipeline stage responsible for creating and
|
||||
# publishing a docker manifest to the registry.
|
||||
def manifest():
|
||||
return {
|
||||
'kind': 'pipeline',
|
||||
'type': 'docker',
|
||||
'name': 'manifest',
|
||||
'steps': [
|
||||
{
|
||||
'name': 'manifest',
|
||||
'image': 'plugins/manifest',
|
||||
'settings': {
|
||||
'auto_tag': 'true',
|
||||
'username': 'drone',
|
||||
'password': {
|
||||
'from_secret': 'docker_password'
|
||||
},
|
||||
'spec': 'docker/manifest.tmpl',
|
||||
'ignore_missing': 'true',
|
||||
},
|
||||
},
|
||||
],
|
||||
'depends_on': [],
|
||||
'trigger': {
|
||||
'event': ['push', 'tag']
|
||||
}
|
||||
}
|
860
.drone.yml
860
.drone.yml
@ -1,226 +1,670 @@
|
||||
---
|
||||
# this file is automatically generated. DO NOT EDIT
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: linux-amd64
|
||||
type: kubernetes
|
||||
name: linter
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
platform:
|
||||
arch: amd64
|
||||
os: linux
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:1.10
|
||||
commands:
|
||||
- cd posix
|
||||
- tar -xf fixtures.tar -C /
|
||||
- go test -v
|
||||
- name: clone
|
||||
image: git.cryptic.systems/volker.raschek/git:1.3.1
|
||||
|
||||
- name: publish
|
||||
image: plugins/docker:18
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.linux.amd64
|
||||
repo: drone/git
|
||||
auto_tag: "true"
|
||||
auto_tag_suffix: linux-amd64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
- name: markdown lint
|
||||
commands:
|
||||
- markdownlint *.md
|
||||
image: git.cryptic.systems/volker.raschek/markdownlint:0.42.0
|
||||
resources:
|
||||
limits:
|
||||
cpu: 150
|
||||
memory: 150M
|
||||
|
||||
- name: email-notification
|
||||
environment:
|
||||
SMTP_FROM_ADDRESS:
|
||||
from_secret: smtp_from_address
|
||||
SMTP_FROM_NAME:
|
||||
from_secret: smtp_from_name
|
||||
SMTP_HOST:
|
||||
from_secret: smtp_host
|
||||
SMTP_USERNAME:
|
||||
from_secret: smtp_username
|
||||
SMTP_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||
resources:
|
||||
limits:
|
||||
cpu: 150
|
||||
memory: 150M
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
exclude:
|
||||
- tag
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: linux-arm64
|
||||
name: dry-run-amd64
|
||||
|
||||
platform:
|
||||
arch: arm64
|
||||
os: linux
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:1.10
|
||||
commands:
|
||||
- cd posix
|
||||
- tar -xf fixtures.tar -C /
|
||||
- go test -v
|
||||
|
||||
- name: publish
|
||||
image: plugins/docker:18
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.linux.arm64
|
||||
repo: drone/git
|
||||
auto_tag: "true"
|
||||
auto_tag_suffix: linux-arm64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: linux-arm
|
||||
|
||||
platform:
|
||||
arch: arm
|
||||
os: linux
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:1.10
|
||||
commands:
|
||||
- cd posix
|
||||
- tar -xf fixtures.tar -C /
|
||||
- go test -v
|
||||
|
||||
- name: publish
|
||||
image: plugins/docker:18
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.linux.arm
|
||||
repo: drone/git
|
||||
auto_tag: "true"
|
||||
auto_tag_suffix: linux-arm
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: ssh
|
||||
name: windows-1909-amd64
|
||||
|
||||
platform:
|
||||
os: windows
|
||||
|
||||
server:
|
||||
host:
|
||||
from_secret: windows_server_1909
|
||||
password:
|
||||
from_secret: windows_password
|
||||
user:
|
||||
from_secret: windows_username
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
commands:
|
||||
- docker login -u $env:USERNAME -p $env:PASSWORD
|
||||
- docker build -f docker/Dockerfile.windows.1909 -t drone/git:windows-1909-amd64 .
|
||||
- docker push drone/git:windows-1909-amd64
|
||||
environment:
|
||||
USERNAME:
|
||||
from_secret: docker_username
|
||||
PASSWORD:
|
||||
from_secret: docker_password
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: ssh
|
||||
name: windows-1903-amd64
|
||||
|
||||
platform:
|
||||
os: windows
|
||||
|
||||
server:
|
||||
host:
|
||||
from_secret: windows_server_1903
|
||||
password:
|
||||
from_secret: windows_password
|
||||
user:
|
||||
from_secret: windows_username
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
commands:
|
||||
- docker login -u $env:USERNAME -p $env:PASSWORD
|
||||
- docker build -f docker/Dockerfile.windows.1903 -t drone/git:windows-1903-amd64 .
|
||||
- docker push drone/git:windows-1903-amd64
|
||||
environment:
|
||||
USERNAME:
|
||||
from_secret: docker_username
|
||||
PASSWORD:
|
||||
from_secret: docker_password
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: ssh
|
||||
name: windows-1809-amd64
|
||||
|
||||
platform:
|
||||
os: windows
|
||||
|
||||
server:
|
||||
host:
|
||||
from_secret: windows_server_1809
|
||||
password:
|
||||
from_secret: windows_password
|
||||
user:
|
||||
from_secret: windows_username
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
commands:
|
||||
- docker login -u $env:USERNAME -p $env:PASSWORD
|
||||
- docker build -f docker/Dockerfile.windows.1809 -t drone/git:windows-1809-amd64 .
|
||||
- docker push drone/git:windows-1809-amd64
|
||||
environment:
|
||||
USERNAME:
|
||||
from_secret: docker_username
|
||||
PASSWORD:
|
||||
from_secret: docker_password
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: manifest
|
||||
|
||||
steps:
|
||||
- name: manifest
|
||||
image: plugins/manifest
|
||||
settings:
|
||||
auto_tag: "true"
|
||||
ignore_missing: "true"
|
||||
spec: docker/manifest.tmpl
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
depends_on:
|
||||
- linux-amd64
|
||||
- linux-arm64
|
||||
- linux-arm
|
||||
- windows-1909-amd64
|
||||
- windows-1903-amd64
|
||||
- windows-1809-amd64
|
||||
- linter
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: clone
|
||||
image: git.cryptic.systems/volker.raschek/git:1.3.1
|
||||
|
||||
- name: build
|
||||
image: docker.io/plugins/docker:20.18.4
|
||||
settings:
|
||||
auto_tag: false
|
||||
dockerfile: Dockerfile
|
||||
dry_run: true
|
||||
force_tag: true
|
||||
no_cache: true
|
||||
purge: true
|
||||
mirror:
|
||||
from_secret: docker_io_mirror
|
||||
registry: git.cryptic.systems
|
||||
repo: git.cryptic.systems/volker.raschek/git
|
||||
tags: latest-amd64
|
||||
username:
|
||||
from_secret: git_cryptic_systems_container_registry_user
|
||||
password:
|
||||
from_secret: git_cryptic_systems_container_registry_password
|
||||
|
||||
- name: email-notification
|
||||
environment:
|
||||
SMTP_FROM_ADDRESS:
|
||||
from_secret: smtp_from_address
|
||||
SMTP_FROM_NAME:
|
||||
from_secret: smtp_from_name
|
||||
SMTP_HOST:
|
||||
from_secret: smtp_host
|
||||
SMTP_USERNAME:
|
||||
from_secret: smtp_username
|
||||
SMTP_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
exclude:
|
||||
- master
|
||||
event:
|
||||
- pull_request
|
||||
- push
|
||||
repo:
|
||||
- volker.raschek/git-docker
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: dry-run-arm64-v8
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
depends_on:
|
||||
- linter
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
steps:
|
||||
- name: clone
|
||||
image: git.cryptic.systems/volker.raschek/git:1.3.1
|
||||
|
||||
- name: build
|
||||
image: docker.io/plugins/docker:20.18.4
|
||||
settings:
|
||||
auto_tag: false
|
||||
dockerfile: Dockerfile
|
||||
dry_run: true
|
||||
force_tag: true
|
||||
no_cache: true
|
||||
purge: true
|
||||
mirror:
|
||||
from_secret: docker_io_mirror
|
||||
registry: git.cryptic.systems
|
||||
repo: git.cryptic.systems/volker.raschek/git
|
||||
tags: latest-arm64-v8
|
||||
username:
|
||||
from_secret: git_cryptic_systems_container_registry_user
|
||||
password:
|
||||
from_secret: git_cryptic_systems_container_registry_password
|
||||
|
||||
- name: email-notification
|
||||
environment:
|
||||
SMTP_FROM_ADDRESS:
|
||||
from_secret: smtp_from_address
|
||||
SMTP_FROM_NAME:
|
||||
from_secret: smtp_from_name
|
||||
SMTP_HOST:
|
||||
from_secret: smtp_host
|
||||
SMTP_USERNAME:
|
||||
from_secret: smtp_username
|
||||
SMTP_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
exclude:
|
||||
- master
|
||||
event:
|
||||
- pull_request
|
||||
- push
|
||||
repo:
|
||||
- volker.raschek/git-docker
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: latest-amd64
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
depends_on:
|
||||
- linter
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: clone
|
||||
image: git.cryptic.systems/volker.raschek/git:1.3.1
|
||||
|
||||
- name: build
|
||||
image: docker.io/plugins/docker:20.18.4
|
||||
settings:
|
||||
auto_tag: false
|
||||
dockerfile: Dockerfile
|
||||
force_tag: true
|
||||
no_cache: true
|
||||
purge: true
|
||||
mirror:
|
||||
from_secret: docker_io_mirror
|
||||
registry: git.cryptic.systems
|
||||
repo: git.cryptic.systems/volker.raschek/git
|
||||
tags: latest-amd64
|
||||
username:
|
||||
from_secret: git_cryptic_systems_container_registry_user
|
||||
password:
|
||||
from_secret: git_cryptic_systems_container_registry_password
|
||||
|
||||
- name: email-notification
|
||||
environment:
|
||||
SMTP_FROM_ADDRESS:
|
||||
from_secret: smtp_from_address
|
||||
SMTP_FROM_NAME:
|
||||
from_secret: smtp_from_name
|
||||
SMTP_HOST:
|
||||
from_secret: smtp_host
|
||||
SMTP_USERNAME:
|
||||
from_secret: smtp_username
|
||||
SMTP_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- cron
|
||||
- push
|
||||
repo:
|
||||
- volker.raschek/git-docker
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: latest-arm64-v8
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
depends_on:
|
||||
- linter
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
steps:
|
||||
- name: clone
|
||||
image: git.cryptic.systems/volker.raschek/git:1.3.1
|
||||
|
||||
- name: build
|
||||
image: docker.io/plugins/docker:20.18.4
|
||||
settings:
|
||||
auto_tag: false
|
||||
dockerfile: Dockerfile
|
||||
force_tag: true
|
||||
no_cache: true
|
||||
purge: true
|
||||
mirror:
|
||||
from_secret: docker_io_mirror
|
||||
registry: git.cryptic.systems
|
||||
repo: git.cryptic.systems/volker.raschek/git
|
||||
tags: latest-arm64-v8
|
||||
username:
|
||||
from_secret: git_cryptic_systems_container_registry_user
|
||||
password:
|
||||
from_secret: git_cryptic_systems_container_registry_password
|
||||
|
||||
- name: email-notification
|
||||
environment:
|
||||
SMTP_FROM_ADDRESS:
|
||||
from_secret: smtp_from_address
|
||||
SMTP_FROM_NAME:
|
||||
from_secret: smtp_from_name
|
||||
SMTP_HOST:
|
||||
from_secret: smtp_host
|
||||
SMTP_USERNAME:
|
||||
from_secret: smtp_username
|
||||
SMTP_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- cron
|
||||
- push
|
||||
repo:
|
||||
- volker.raschek/git-docker
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: kubernetes
|
||||
name: latest-manifest
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
depends_on:
|
||||
- latest-amd64
|
||||
- latest-arm64-v8
|
||||
|
||||
# docker.io/plugins/manifest only for amd64 architectures available
|
||||
node_selector:
|
||||
kubernetes.io/os: linux
|
||||
kubernetes.io/arch: amd64
|
||||
|
||||
steps:
|
||||
- name: clone
|
||||
image: git.cryptic.systems/volker.raschek/git:1.3.1
|
||||
|
||||
- name: build-manifest
|
||||
image: docker.io/plugins/manifest:1.4.0
|
||||
settings:
|
||||
auto_tag: false
|
||||
ignore_missing: true
|
||||
spec: manifest.tmpl
|
||||
username:
|
||||
from_secret: git_cryptic_systems_container_registry_user
|
||||
password:
|
||||
from_secret: git_cryptic_systems_container_registry_password
|
||||
|
||||
- name: email-notification
|
||||
environment:
|
||||
SMTP_FROM_ADDRESS:
|
||||
from_secret: smtp_from_address
|
||||
SMTP_FROM_NAME:
|
||||
from_secret: smtp_from_name
|
||||
SMTP_HOST:
|
||||
from_secret: smtp_host
|
||||
SMTP_USERNAME:
|
||||
from_secret: smtp_username
|
||||
SMTP_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||
resources:
|
||||
limits:
|
||||
cpu: 150
|
||||
memory: 150M
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- cron
|
||||
- push
|
||||
repo:
|
||||
- volker.raschek/git-docker
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: kubernetes
|
||||
name: latest-sync
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
depends_on:
|
||||
- latest-manifest
|
||||
|
||||
steps:
|
||||
- name: clone
|
||||
image: git.cryptic.systems/volker.raschek/git:1.3.1
|
||||
|
||||
- name: latest-sync
|
||||
commands:
|
||||
- skopeo sync --all --src=docker --src-creds=$SRC_CRED_USERNAME:$SRC_CRED_PASSWORD --dest=docker --dest-creds=$DEST_CRED_USERNAME:$DEST_CRED_PASSWORD git.cryptic.systems/volker.raschek/git docker.io/volkerraschek
|
||||
environment:
|
||||
SRC_CRED_USERNAME:
|
||||
from_secret: git_cryptic_systems_container_registry_user
|
||||
SRC_CRED_PASSWORD:
|
||||
from_secret: git_cryptic_systems_container_registry_password
|
||||
DEST_CRED_USERNAME:
|
||||
from_secret: container_image_registry_user
|
||||
DEST_CRED_PASSWORD:
|
||||
from_secret: container_image_registry_password
|
||||
image: quay.io/skopeo/stable:v1.17.0
|
||||
|
||||
- name: email-notification
|
||||
environment:
|
||||
SMTP_FROM_ADDRESS:
|
||||
from_secret: smtp_from_address
|
||||
SMTP_FROM_NAME:
|
||||
from_secret: smtp_from_name
|
||||
SMTP_HOST:
|
||||
from_secret: smtp_host
|
||||
SMTP_USERNAME:
|
||||
from_secret: smtp_username
|
||||
SMTP_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||
resources:
|
||||
limits:
|
||||
cpu: 150
|
||||
memory: 150M
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- cron
|
||||
- push
|
||||
repo:
|
||||
- volker.raschek/git-docker
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: tagged-amd64
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: clone
|
||||
image: git.cryptic.systems/volker.raschek/git:1.3.1
|
||||
|
||||
- name: build
|
||||
image: docker.io/plugins/docker:20.18.4
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: amd64
|
||||
dockerfile: Dockerfile
|
||||
force_tag: true
|
||||
no_cache: true
|
||||
purge: true
|
||||
mirror:
|
||||
from_secret: docker_io_mirror
|
||||
registry: git.cryptic.systems
|
||||
repo: git.cryptic.systems/volker.raschek/git
|
||||
username:
|
||||
from_secret: git_cryptic_systems_container_registry_user
|
||||
password:
|
||||
from_secret: git_cryptic_systems_container_registry_password
|
||||
build_args:
|
||||
- GOSEC_VERSION=${DRONE_TAG}
|
||||
|
||||
- name: email-notification
|
||||
environment:
|
||||
SMTP_FROM_ADDRESS:
|
||||
from_secret: smtp_from_address
|
||||
SMTP_FROM_NAME:
|
||||
from_secret: smtp_from_name
|
||||
SMTP_HOST:
|
||||
from_secret: smtp_host
|
||||
SMTP_USERNAME:
|
||||
from_secret: smtp_username
|
||||
SMTP_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
repo:
|
||||
- volker.raschek/git-docker
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: tagged-arm64-v8
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
steps:
|
||||
- name: clone
|
||||
image: git.cryptic.systems/volker.raschek/git:1.3.1
|
||||
|
||||
- name: build
|
||||
image: docker.io/plugins/docker:20.18.4
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: arm64-v8
|
||||
dockerfile: Dockerfile
|
||||
force_tag: true
|
||||
no_cache: true
|
||||
purge: true
|
||||
mirror:
|
||||
from_secret: docker_io_mirror
|
||||
registry: git.cryptic.systems
|
||||
repo: git.cryptic.systems/volker.raschek/git
|
||||
username:
|
||||
from_secret: git_cryptic_systems_container_registry_user
|
||||
password:
|
||||
from_secret: git_cryptic_systems_container_registry_password
|
||||
build_args:
|
||||
- GOSEC_VERSION=${DRONE_TAG}
|
||||
|
||||
- name: email-notification
|
||||
environment:
|
||||
SMTP_FROM_ADDRESS:
|
||||
from_secret: smtp_from_address
|
||||
SMTP_FROM_NAME:
|
||||
from_secret: smtp_from_name
|
||||
SMTP_HOST:
|
||||
from_secret: smtp_host
|
||||
SMTP_USERNAME:
|
||||
from_secret: smtp_username
|
||||
SMTP_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
repo:
|
||||
- volker.raschek/git-docker
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: kubernetes
|
||||
name: tagged-manifest
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
depends_on:
|
||||
- tagged-amd64
|
||||
- tagged-arm64-v8
|
||||
|
||||
# docker.io/plugins/manifest only for amd64 architectures available
|
||||
node_selector:
|
||||
kubernetes.io/os: linux
|
||||
kubernetes.io/arch: amd64
|
||||
|
||||
steps:
|
||||
- name: clone
|
||||
image: git.cryptic.systems/volker.raschek/git:1.3.1
|
||||
|
||||
- name: build-manifest
|
||||
image: docker.io/plugins/manifest:1.4.0
|
||||
settings:
|
||||
auto_tag: true
|
||||
ignore_missing: true
|
||||
spec: manifest.tmpl
|
||||
username:
|
||||
from_secret: git_cryptic_systems_container_registry_user
|
||||
password:
|
||||
from_secret: git_cryptic_systems_container_registry_password
|
||||
|
||||
- name: email-notification
|
||||
environment:
|
||||
SMTP_FROM_ADDRESS:
|
||||
from_secret: smtp_from_address
|
||||
SMTP_FROM_NAME:
|
||||
from_secret: smtp_from_name
|
||||
SMTP_HOST:
|
||||
from_secret: smtp_host
|
||||
SMTP_USERNAME:
|
||||
from_secret: smtp_username
|
||||
SMTP_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||
resources:
|
||||
limits:
|
||||
cpu: 150
|
||||
memory: 150M
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
repo:
|
||||
- volker.raschek/git-docker
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: kubernetes
|
||||
name: tagged-sync
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
depends_on:
|
||||
- tagged-manifest
|
||||
|
||||
steps:
|
||||
- name: clone
|
||||
image: git.cryptic.systems/volker.raschek/git:1.3.1
|
||||
|
||||
- name: tagged-sync
|
||||
commands:
|
||||
- skopeo sync --all --src=docker --src-creds=$SRC_CRED_USERNAME:$SRC_CRED_PASSWORD --dest=docker --dest-creds=$DEST_CRED_USERNAME:$DEST_CRED_PASSWORD git.cryptic.systems/volker.raschek/git docker.io/volkerraschek
|
||||
environment:
|
||||
SRC_CRED_USERNAME:
|
||||
from_secret: git_cryptic_systems_container_registry_user
|
||||
SRC_CRED_PASSWORD:
|
||||
from_secret: git_cryptic_systems_container_registry_password
|
||||
DEST_CRED_USERNAME:
|
||||
from_secret: container_image_registry_user
|
||||
DEST_CRED_PASSWORD:
|
||||
from_secret: container_image_registry_password
|
||||
image: quay.io/skopeo/stable:v1.17.0
|
||||
|
||||
- name: email-notification
|
||||
environment:
|
||||
SMTP_FROM_ADDRESS:
|
||||
from_secret: smtp_from_address
|
||||
SMTP_FROM_NAME:
|
||||
from_secret: smtp_from_name
|
||||
SMTP_HOST:
|
||||
from_secret: smtp_host
|
||||
SMTP_USERNAME:
|
||||
from_secret: smtp_username
|
||||
SMTP_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||
resources:
|
||||
limits:
|
||||
cpu: 150
|
||||
memory: 150M
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
repo:
|
||||
- volker.raschek/git-docker
|
||||
|
12
.editorconfig
Normal file
12
.editorconfig
Normal file
@ -0,0 +1,12 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = false
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
Makefile eol=lf
|
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
144
.markdownlint.yaml
Normal file
144
.markdownlint.yaml
Normal file
@ -0,0 +1,144 @@
|
||||
# markdownlint YAML configuration
|
||||
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
|
||||
|
||||
# Default state for all rules
|
||||
default: true
|
||||
|
||||
# Path to configuration file to extend
|
||||
extends: null
|
||||
|
||||
# MD003/heading-style/header-style - Heading style
|
||||
MD003:
|
||||
# Heading style
|
||||
style: "atx"
|
||||
|
||||
# MD004/ul-style - Unordered list style
|
||||
MD004:
|
||||
style: "dash"
|
||||
|
||||
# MD007/ul-indent - Unordered list indentation
|
||||
MD007:
|
||||
# Spaces for indent
|
||||
indent: 2
|
||||
# Whether to indent the first level of the list
|
||||
start_indented: false
|
||||
|
||||
# MD009/no-trailing-spaces - Trailing spaces
|
||||
MD009:
|
||||
# Spaces for line break
|
||||
br_spaces: 2
|
||||
# Allow spaces for empty lines in list items
|
||||
list_item_empty_lines: false
|
||||
# Include unnecessary breaks
|
||||
strict: false
|
||||
|
||||
# MD010/no-hard-tabs - Hard tabs
|
||||
MD010:
|
||||
# Include code blocks
|
||||
code_blocks: true
|
||||
|
||||
# MD012/no-multiple-blanks - Multiple consecutive blank lines
|
||||
MD012:
|
||||
# Consecutive blank lines
|
||||
maximum: 1
|
||||
|
||||
# MD013/line-length - Line length
|
||||
MD013:
|
||||
# Number of characters
|
||||
line_length: 80
|
||||
# Number of characters for headings
|
||||
heading_line_length: 80
|
||||
# Number of characters for code blocks
|
||||
code_block_line_length: 80
|
||||
# Include code blocks
|
||||
code_blocks: false
|
||||
# Include tables
|
||||
tables: false
|
||||
# Include headings
|
||||
headings: true
|
||||
# Include headings
|
||||
headers: true
|
||||
# Strict length checking
|
||||
strict: false
|
||||
# Stern length checking
|
||||
stern: false
|
||||
|
||||
# MD022/blanks-around-headings/blanks-around-headers - Headings should be surrounded by blank lines
|
||||
MD022:
|
||||
# Blank lines above heading
|
||||
lines_above: 1
|
||||
# Blank lines below heading
|
||||
lines_below: 1
|
||||
|
||||
# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
|
||||
MD024:
|
||||
# Only check sibling headings
|
||||
allow_different_nesting: true
|
||||
|
||||
# MD025/single-title/single-h1 - Multiple top-level headings in the same document
|
||||
MD025:
|
||||
# Heading level
|
||||
level: 1
|
||||
# RegExp for matching title in front matter
|
||||
front_matter_title: "^\\s*title\\s*[:=]"
|
||||
|
||||
# MD026/no-trailing-punctuation - Trailing punctuation in heading
|
||||
MD026:
|
||||
# Punctuation characters
|
||||
punctuation: ".,;:!。,;:!"
|
||||
|
||||
# MD029/ol-prefix - Ordered list item prefix
|
||||
MD029:
|
||||
# List style
|
||||
style: "one_or_ordered"
|
||||
|
||||
# MD030/list-marker-space - Spaces after list markers
|
||||
MD030:
|
||||
# Spaces for single-line unordered list items
|
||||
ul_single: 1
|
||||
# Spaces for single-line ordered list items
|
||||
ol_single: 1
|
||||
# Spaces for multi-line unordered list items
|
||||
ul_multi: 1
|
||||
# Spaces for multi-line ordered list items
|
||||
ol_multi: 1
|
||||
|
||||
# MD033/no-inline-html - Inline HTML
|
||||
MD033:
|
||||
# Allowed elements
|
||||
allowed_elements: []
|
||||
|
||||
# MD035/hr-style - Horizontal rule style
|
||||
MD035:
|
||||
# Horizontal rule style
|
||||
style: "---"
|
||||
|
||||
# MD036/no-emphasis-as-heading/no-emphasis-as-header - Emphasis used instead of a heading
|
||||
MD036:
|
||||
# Punctuation characters
|
||||
punctuation: ".,;:!?。,;:!?"
|
||||
|
||||
# MD041/first-line-heading/first-line-h1 - First line in a file should be a top-level heading
|
||||
MD041:
|
||||
# Heading level
|
||||
level: 1
|
||||
# RegExp for matching title in front matter
|
||||
front_matter_title: "^\\s*title\\s*[:=]"
|
||||
|
||||
# MD044/proper-names - Proper names should have the correct capitalization
|
||||
MD044:
|
||||
# List of proper names
|
||||
names:
|
||||
- helm
|
||||
# Include code blocks
|
||||
code_blocks: false
|
||||
|
||||
# MD046/code-block-style - Code block style
|
||||
MD046:
|
||||
# Block style
|
||||
style: "fenced"
|
||||
|
||||
# MD048/code-fence-style - Code fence style
|
||||
MD048:
|
||||
# Code fence syle
|
||||
style: "backtick"
|
21
CHANGELOG.md
21
CHANGELOG.md
@ -1,21 +0,0 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
|
||||
## [1.1.0]
|
||||
### Added
|
||||
|
||||
- Ability to clone tags for promotion events from [@josmo](https://github.com/josme)
|
||||
- Support for git lfs in base images from [@carlwgeorge](https://github.com/carlwgeorge)
|
||||
- Support for windows 1803 from [@donny-dont](https://github.com/donny-dont)
|
||||
- Support for windows 1809 from [@donny-dont](https://github.com/donny-dont)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed error merging when missing email from [@bradrydzewski](https://github.com/bradrydzewski)
|
||||
- Fixed empty ref on windows from [@drpebcak](https://github.com/drpebcak)
|
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@ -0,0 +1,19 @@
|
||||
FROM docker.io/library/alpine:3.20.3
|
||||
RUN apk add --no-cache \
|
||||
bash \
|
||||
ca-certificates \
|
||||
curl \
|
||||
git \
|
||||
git-lfs \
|
||||
openssh \
|
||||
perl \
|
||||
sudo
|
||||
|
||||
ADD rootfs /
|
||||
|
||||
# RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
|
||||
# RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
|
||||
# USER drone:drone
|
||||
# RUN chmod -R 777 /home/drone
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
47
Makefile
Normal file
47
Makefile
Normal file
@ -0,0 +1,47 @@
|
||||
# CONTAINER_RUNTIME
|
||||
# The CONTAINER_RUNTIME variable will be used to specified the path to a
|
||||
# container runtime. This is needed to start and run a container image.
|
||||
CONTAINER_RUNTIME?=$(shell which podman)
|
||||
|
||||
# GIT_IMAGE_REGISTRY_NAME
|
||||
# Defines the name of the new container to be built using several variables.
|
||||
GIT_IMAGE_REGISTRY_NAME:=git.cryptic.systems
|
||||
GIT_IMAGE_REGISTRY_USER:=volker.raschek
|
||||
|
||||
GIT_IMAGE_NAMESPACE?=${GIT_IMAGE_REGISTRY_USER}
|
||||
GIT_IMAGE_NAME:=git
|
||||
GIT_IMAGE_VERSION?=latest
|
||||
GIT_IMAGE_FULLY_QUALIFIED=${GIT_IMAGE_REGISTRY_NAME}/${GIT_IMAGE_NAMESPACE}/${GIT_IMAGE_NAME}:${GIT_IMAGE_VERSION}
|
||||
GIT_IMAGE_UNQUALIFIED=${GIT_IMAGE_NAMESPACE}/${GIT_IMAGE_NAME}:${GIT_IMAGE_VERSION}
|
||||
|
||||
# BUILD CONTAINER IMAGE
|
||||
# ==============================================================================
|
||||
PHONY:=container-image/build
|
||||
container-image/build:
|
||||
${CONTAINER_RUNTIME} build \
|
||||
--file Dockerfile \
|
||||
--no-cache \
|
||||
--pull \
|
||||
--tag ${GIT_IMAGE_FULLY_QUALIFIED} \
|
||||
--tag ${GIT_IMAGE_UNQUALIFIED} \
|
||||
.
|
||||
|
||||
# DELETE CONTAINER IMAGE
|
||||
# ==============================================================================
|
||||
PHONY:=container-image/delete
|
||||
container-image/delete:
|
||||
- ${CONTAINER_RUNTIME} image rm ${GIT_IMAGE_FULLY_QUALIFIED} ${GIT_IMAGE_UNQUALIFIED}
|
||||
- ${CONTAINER_RUNTIME} image rm ${BASE_IMAGE_FULL}
|
||||
|
||||
# PUSH CONTAINER IMAGE
|
||||
# ==============================================================================
|
||||
PHONY+=container-image/push
|
||||
container-image/push:
|
||||
echo ${GIT_IMAGE_REGISTRY_PASSWORD} | ${CONTAINER_RUNTIME} login ${GIT_IMAGE_REGISTRY_NAME} --username ${GIT_IMAGE_REGISTRY_USER} --password-stdin
|
||||
${CONTAINER_RUNTIME} push ${GIT_IMAGE_FULLY_QUALIFIED}
|
||||
|
||||
# PHONY
|
||||
# ==============================================================================
|
||||
# Declare the contents of the PHONY variable as phony. We keep that information
|
||||
# in a variable so we can use it in if_changed.
|
||||
.PHONY: ${PHONY}
|
34
README.md
34
README.md
@ -1,24 +1,34 @@
|
||||
# drone-git
|
||||
# git-docker
|
||||
|
||||
Drone plugin to clone `git` repositories.
|
||||
This is a fork of the official project to clone git repositories from a SCM
|
||||
control system like github, gitlab, gitea, gogs and so on. The difference
|
||||
between the origin and this fork is that this project supports ARM and the shell
|
||||
scripts are tested against shellchecker.
|
||||
|
||||
Among other things, the project experiences more extensive support, as the
|
||||
project receives continuous updates thanks to renovate.
|
||||
|
||||
## Build
|
||||
|
||||
Build the Docker image with the following commands:
|
||||
The container image can be build with via `make` and requires `docker` or
|
||||
`podman`.
|
||||
|
||||
```
|
||||
docker build --rm -f docker/Dockerfile.linux.amd64 -t drone/git .
|
||||
```bash
|
||||
make container-image/build CONTAINER_RUNTIME=docker # or
|
||||
make container-image/build CONTAINER_RUNTIME=podman
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Clone a commit:
|
||||
|
||||
```
|
||||
docker run --rm \
|
||||
-e DRONE_REMOTE_URL=https://github.com/drone/envsubst.git \
|
||||
-e DRONE_BUILD_EVENT=push \
|
||||
-e DRONE_COMMIT_SHA=15e3f9b7e16332eee3bbdff9ef31f95d23c5da2c \
|
||||
-e DRONE_COMMIT_BRANCH=master \
|
||||
drone/git
|
||||
```bash
|
||||
podman run \
|
||||
--rm \
|
||||
--env DRONE_BUILD_EVENT=push \
|
||||
--env DRONE_COMMIT_BRANCH=master \
|
||||
--env DRONE_REMOTE_URL=https://git.cryptic.systems/volker.raschek/git-docker.git \
|
||||
--env DRONE_WORKSPACE=/workspace \
|
||||
--volume /tmp/workspace:/workspace \
|
||||
volker.raschek/git:latest
|
||||
```
|
||||
|
@ -1,10 +0,0 @@
|
||||
FROM alpine:3.12
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
|
||||
RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
|
||||
USER drone:drone
|
||||
RUN chmod -R 777 /home/drone
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
@ -1,5 +0,0 @@
|
||||
FROM arm32v6/alpine:3.12
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
@ -1,5 +0,0 @@
|
||||
FROM arm32v6/alpine:3.12
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
@ -1,5 +0,0 @@
|
||||
FROM arm64v8/alpine:3.12
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
@ -1,5 +0,0 @@
|
||||
FROM arm32v6/alpine:3.12
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
@ -1,5 +0,0 @@
|
||||
FROM arm64v8/alpine:3.12
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
@ -1,20 +0,0 @@
|
||||
# escape=`
|
||||
|
||||
FROM mcr.microsoft.com/windows/servercore:1803 AS git
|
||||
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
|
||||
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
|
||||
Expand-Archive git.zip -DestinationPath C:\git;
|
||||
|
||||
FROM mcr.microsoft.com/powershell:nanoserver-1803
|
||||
COPY --from=git /git /git
|
||||
|
||||
ADD windows/* /bin/
|
||||
|
||||
# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137
|
||||
USER ContainerAdministrator
|
||||
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
|
||||
|
||||
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
|
@ -1,20 +0,0 @@
|
||||
# escape=`
|
||||
|
||||
FROM mcr.microsoft.com/windows/servercore:1809 AS git
|
||||
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
|
||||
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
|
||||
Expand-Archive git.zip -DestinationPath C:\git;
|
||||
|
||||
FROM mcr.microsoft.com/powershell:nanoserver-1809
|
||||
COPY --from=git /git /git
|
||||
|
||||
ADD windows/* /bin/
|
||||
|
||||
# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137
|
||||
USER ContainerAdministrator
|
||||
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
|
||||
|
||||
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
|
@ -1,20 +0,0 @@
|
||||
# escape=`
|
||||
|
||||
FROM mcr.microsoft.com/windows/servercore:1903 AS git
|
||||
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
|
||||
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
|
||||
Expand-Archive git.zip -DestinationPath C:\git;
|
||||
|
||||
FROM mcr.microsoft.com/powershell:nanoserver-1903
|
||||
COPY --from=git /git /git
|
||||
|
||||
ADD windows/* /bin/
|
||||
|
||||
# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137
|
||||
USER ContainerAdministrator
|
||||
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
|
||||
|
||||
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
|
@ -1,20 +0,0 @@
|
||||
# escape=`
|
||||
|
||||
FROM mcr.microsoft.com/windows/servercore:1909 AS git
|
||||
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
|
||||
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
|
||||
Expand-Archive git.zip -DestinationPath C:\git;
|
||||
|
||||
FROM mcr.microsoft.com/powershell:nanoserver-1909
|
||||
COPY --from=git /git /git
|
||||
|
||||
ADD windows/* /bin/
|
||||
|
||||
# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137
|
||||
USER ContainerAdministrator
|
||||
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
|
||||
|
||||
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
|
@ -1,55 +0,0 @@
|
||||
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||
platform:
|
||||
variant: v8
|
||||
architecture: arm64
|
||||
os: linux
|
||||
-
|
||||
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||
platform:
|
||||
variant: v7
|
||||
architecture: arm
|
||||
os: linux
|
||||
-
|
||||
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||
platform:
|
||||
variant: v6
|
||||
architecture: arm
|
||||
os: linux
|
||||
-
|
||||
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1803
|
||||
-
|
||||
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1809
|
||||
-
|
||||
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1903
|
||||
-
|
||||
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1909
|
20
manifest.tmpl
Normal file
20
manifest.tmpl
Normal file
@ -0,0 +1,20 @@
|
||||
image: git.cryptic.systems/volker.raschek/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
- "latest"
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: git.cryptic.systems/volker.raschek/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: git.cryptic.systems/volker.raschek/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-arm64-v8
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
variant: v8
|
103
posix/clone
103
posix/clone
@ -1,103 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [[ ! -z "${DRONE_WORKSPACE}" ]]; then
|
||||
if [[ -n "${CI}" ]]; then
|
||||
sudo mkdir -p ${DRONE_WORKSPACE}
|
||||
sudo chown drone:drone ${DRONE_WORKSPACE}
|
||||
else
|
||||
mkdir -p ${DRONE_WORKSPACE}
|
||||
fi
|
||||
cd ${DRONE_WORKSPACE}
|
||||
fi
|
||||
|
||||
# we default home directory to /home/drone
|
||||
|
||||
if [ "$HOME" != "/home/drone" ]; then
|
||||
export HOME=/home/drone
|
||||
fi
|
||||
|
||||
# if the home directory does not exist it should
|
||||
# be created.
|
||||
|
||||
if [ ! -d "${HOME}" ]; then
|
||||
echo "HOME directory does not exist; creating ${HOME}"
|
||||
mkdir -p ${HOME}
|
||||
fi
|
||||
|
||||
# if the netrc enviornment variables exist, write
|
||||
# the netrc file.
|
||||
|
||||
if [[ ! -z "${DRONE_NETRC_MACHINE}" ]]; then
|
||||
cat <<EOF > ${HOME}/.netrc
|
||||
machine ${DRONE_NETRC_MACHINE}
|
||||
login ${DRONE_NETRC_USERNAME}
|
||||
password ${DRONE_NETRC_PASSWORD}
|
||||
EOF
|
||||
fi
|
||||
|
||||
# if the ssh_key environment variable exists, write
|
||||
# the ssh key and add the netrc machine to the
|
||||
# known hosts file.
|
||||
|
||||
if [[ ! -z "${DRONE_SSH_KEY}" ]]; then
|
||||
mkdir ${HOME}/.ssh
|
||||
echo -n "$DRONE_SSH_KEY" > ${HOME}/.ssh/id_rsa
|
||||
chmod 600 ${HOME}/.ssh/id_rsa
|
||||
|
||||
touch ${HOME}/.ssh/known_hosts
|
||||
chmod 600 ${HOME}/.ssh/known_hosts
|
||||
ssh-keyscan -H ${DRONE_NETRC_MACHINE} > /etc/ssh/ssh_known_hosts 2> /dev/null
|
||||
fi
|
||||
|
||||
# AWS codecommit support using AWS access key & secret key
|
||||
# Refer: https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-unixes.html
|
||||
|
||||
if [[ ! -z "$DRONE_AWS_ACCESS_KEY" ]]; then
|
||||
aws configure set aws_access_key_id $DRONE_AWS_ACCESS_KEY
|
||||
aws configure set aws_secret_access_key $DRONE_AWS_SECRET_KEY
|
||||
aws configure set default.region $DRONE_AWS_REGION
|
||||
|
||||
git config --global credential.helper '!aws codecommit credential-helper $@'
|
||||
git config --global credential.UseHttpPath true
|
||||
fi
|
||||
|
||||
# configure git global behavior and parameters via the
|
||||
# following environment variables:
|
||||
|
||||
|
||||
if [[ -z "${DRONE_COMMIT_AUTHOR_NAME}" ]]; then
|
||||
export DRONE_COMMIT_AUTHOR_NAME=drone
|
||||
fi
|
||||
|
||||
if [[ -z "${DRONE_COMMIT_AUTHOR_EMAIL}" ]]; then
|
||||
export DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost
|
||||
fi
|
||||
|
||||
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||
export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||
export GIT_COMMITTER_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||
export GIT_COMMITTER_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||
|
||||
# invoke the sub-script based on the drone event type.
|
||||
# TODO we should ultimately look at the ref, since
|
||||
# we need something compatible with deployment events.
|
||||
|
||||
CLONE_TYPE=$DRONE_BUILD_EVENT
|
||||
case $DRONE_COMMIT_REF in
|
||||
refs/tags/* ) CLONE_TYPE=tag ;;
|
||||
refs/pull/* ) CLONE_TYPE=pull_request ;;
|
||||
refs/pull-request/* ) CLONE_TYPE=pull_request ;;
|
||||
refs/merge-requests/* ) CLONE_TYPE=pull_request ;;
|
||||
esac
|
||||
|
||||
case $CLONE_TYPE in
|
||||
pull_request)
|
||||
clone-pull-request
|
||||
;;
|
||||
tag)
|
||||
clone-tag
|
||||
;;
|
||||
*)
|
||||
clone-commit
|
||||
;;
|
||||
esac
|
@ -1,41 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
FLAGS=""
|
||||
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
|
||||
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||
fi
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
git remote add origin ${DRONE_REMOTE_URL}
|
||||
fi
|
||||
|
||||
# the branch may be empty for certain event types,
|
||||
# such as github deployment events. If the branch
|
||||
# is empty we checkout the sha directly. Note that
|
||||
# we intentially omit depth flags to avoid failed
|
||||
# clones due to lack of history.
|
||||
if [[ -z "${DRONE_COMMIT_BRANCH}" ]]; then
|
||||
set -e
|
||||
set -x
|
||||
git fetch origin
|
||||
git checkout -qf ${DRONE_COMMIT_SHA}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# the commit sha may be empty for builds that are
|
||||
# manually triggered in Harness CI Enterprise. If
|
||||
# the commit is empty we clone the branch.
|
||||
if [[ -z "${DRONE_COMMIT_SHA}" ]]; then
|
||||
set -e
|
||||
set -x
|
||||
git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
|
||||
git checkout -b ${DRONE_COMMIT_BRANCH} origin/${DRONE_COMMIT_BRANCH}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
|
||||
git checkout ${DRONE_COMMIT_SHA} -b ${DRONE_COMMIT_BRANCH}
|
@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
FLAGS=""
|
||||
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
|
||||
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||
fi
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
git remote add origin ${DRONE_REMOTE_URL}
|
||||
fi
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
|
||||
git checkout ${DRONE_COMMIT_BRANCH}
|
||||
|
||||
git fetch origin ${DRONE_COMMIT_REF}:
|
||||
git merge ${DRONE_COMMIT_SHA}
|
@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
FLAGS=""
|
||||
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
|
||||
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||
fi
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
git remote add origin ${DRONE_REMOTE_URL}
|
||||
fi
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
git fetch ${FLAGS} origin +refs/tags/${DRONE_TAG}:
|
||||
git checkout -qf FETCH_HEAD
|
@ -1,40 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script creates a git repository and seeds with
|
||||
# commit history. Used by unit tests.
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
rm -rf /tmp/remote/greeting
|
||||
mkdir -p /tmp/remote/greeting
|
||||
pushd /tmp/remote/greeting
|
||||
|
||||
git init
|
||||
|
||||
echo "hi world" > hello.txt
|
||||
git add hello.txt
|
||||
git commit -m "say hi"
|
||||
git tag v1.0.0
|
||||
|
||||
echo "hello world" > hello.txt
|
||||
git add hello.txt
|
||||
git commit -m "say hello"
|
||||
git tag v1.1.0
|
||||
|
||||
git checkout -b fr
|
||||
|
||||
echo "salut monde" > hello.txt
|
||||
git add hello.txt
|
||||
git commit -m "say hello in french"
|
||||
git tag v2.0.0
|
||||
|
||||
echo "bonjour monde" > hello.txt
|
||||
git add hello.txt
|
||||
git commit -m "say hello en francais"
|
||||
git tag v2.1.0
|
||||
|
||||
git checkout master
|
||||
|
||||
popd
|
||||
tar -cvf fixtures.tar /tmp/remote/greeting
|
Binary file not shown.
@ -1,3 +0,0 @@
|
||||
package posix
|
||||
|
||||
//go:generate go run ../scripts/includetext.go --input=clone --input=clone-commit --input=clone-pull-request --input=clone-tag --package=posix --output=posix_gen.go
|
@ -1,138 +0,0 @@
|
||||
package posix
|
||||
|
||||
// DO NOT EDIT. This file is automatically generated.
|
||||
|
||||
// Contents of clone
|
||||
const Clone = `#!/bin/sh
|
||||
|
||||
if [[ ! -z "${DRONE_WORKSPACE}" ]]; then
|
||||
cd ${DRONE_WORKSPACE}
|
||||
fi
|
||||
|
||||
# if the netrc enviornment variables exist, write
|
||||
# the netrc file.
|
||||
|
||||
if [[ ! -z "${DRONE_NETRC_MACHINE}" ]]; then
|
||||
cat <<EOF > /root/.netrc
|
||||
machine ${DRONE_NETRC_MACHINE}
|
||||
login ${DRONE_NETRC_USERNAME}
|
||||
password ${DRONE_NETRC_PASSWORD}
|
||||
EOF
|
||||
fi
|
||||
|
||||
# if the ssh_key environment variable exists, write
|
||||
# the ssh key and add the netrc machine to the
|
||||
# known hosts file.
|
||||
|
||||
if [[ ! -z "${SSH_KEY}" ]]; then
|
||||
mkdir /root/.ssh
|
||||
echo -n "$SSH_KEY" > /root/.ssh/id_rsa
|
||||
chmod 600 /root/.ssh/id_rsa
|
||||
|
||||
touch /root/.ssh/known_hosts
|
||||
chmod 600 /root/.ssh/known_hosts
|
||||
ssh-keyscan -H ${DRONE_NETRC_MACHINE} > /etc/ssh/ssh_known_hosts 2> /dev/null
|
||||
fi
|
||||
|
||||
# configure git global behavior and parameters via the
|
||||
# following environment variables:
|
||||
|
||||
|
||||
if [[ -z "${DRONE_COMMIT_AUTHOR_NAME}" ]]; then
|
||||
export DRONE_COMMIT_AUTHOR_NAME=drone
|
||||
fi
|
||||
|
||||
if [[ -z "${DRONE_COMMIT_AUTHOR_EMAIL}" ]]; then
|
||||
export DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost
|
||||
fi
|
||||
|
||||
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||
export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||
export GIT_COMMITTER_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||
export GIT_COMMITTER_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||
|
||||
# invoke the sub-script based on the drone event type.
|
||||
# TODO we should ultimately look at the ref, since
|
||||
# we need something compatible with deployment events.
|
||||
|
||||
CLONE_TYPE=$DRONE_BUILD_EVENT
|
||||
case $DRONE_COMMIT_REF in
|
||||
refs/tags/* ) CLONE_TYPE=tag ;;
|
||||
esac
|
||||
|
||||
case $CLONE_TYPE in
|
||||
pull_request)
|
||||
clone-pull-request
|
||||
;;
|
||||
tag)
|
||||
clone-tag
|
||||
;;
|
||||
*)
|
||||
clone-commit
|
||||
;;
|
||||
esac
|
||||
`
|
||||
|
||||
// Contents of clone-commit
|
||||
const CloneCommit = `#!/bin/sh
|
||||
|
||||
FLAGS=""
|
||||
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
|
||||
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||
fi
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
git remote add origin ${DRONE_REMOTE_URL}
|
||||
fi
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
|
||||
git checkout ${DRONE_COMMIT_SHA} -b ${DRONE_COMMIT_BRANCH}
|
||||
`
|
||||
|
||||
// Contents of clone-pull-request
|
||||
const ClonePullRequest = `#!/bin/sh
|
||||
|
||||
FLAGS=""
|
||||
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
|
||||
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||
fi
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
git remote add origin ${DRONE_REMOTE_URL}
|
||||
fi
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
|
||||
git checkout ${DRONE_COMMIT_BRANCH}
|
||||
|
||||
git fetch origin ${DRONE_COMMIT_REF}:
|
||||
git merge ${DRONE_COMMIT_SHA}
|
||||
`
|
||||
|
||||
// Contents of clone-tag
|
||||
const CloneTag = `#!/bin/sh
|
||||
|
||||
FLAGS=""
|
||||
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
|
||||
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||
fi
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
git remote add origin ${DRONE_REMOTE_URL}
|
||||
fi
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
git fetch ${FLAGS} origin +refs/tags/${DRONE_TAG}:
|
||||
git checkout -qf FETCH_HEAD
|
||||
`
|
||||
|
@ -1,259 +0,0 @@
|
||||
package posix
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCommits(t *testing.T) {
|
||||
remote := "/tmp/remote/greeting"
|
||||
|
||||
base, err := ioutil.TempDir("", "test")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
defer os.Remove(base)
|
||||
|
||||
for i, test := range tests {
|
||||
local := filepath.Join(base, fmt.Sprint(i))
|
||||
err = os.MkdirAll(local, 0777)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
bin, err := filepath.Abs("clone-commit")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
cmd := exec.Command(bin)
|
||||
cmd.Dir = local
|
||||
cmd.Env = []string{
|
||||
fmt.Sprintf("DRONE_COMMIT_BRANCH=%s", test.branch),
|
||||
fmt.Sprintf("DRONE_COMMIT_SHA=%s", test.commit),
|
||||
fmt.Sprintf("DRONE_WORKSPACE=%s", local),
|
||||
fmt.Sprintf("DRONE_REMOTE_URL=%s", remote),
|
||||
}
|
||||
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Log(string(out))
|
||||
return
|
||||
}
|
||||
|
||||
commit, err := getCommit(local)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
branch, err := getBranch(local)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
if want, got := test.commit, commit; got != want {
|
||||
t.Errorf("Want commit %s, got %s", want, got)
|
||||
}
|
||||
|
||||
if want, got := test.branch, branch; got != want {
|
||||
t.Errorf("Want branch %s, got %s", want, got)
|
||||
}
|
||||
|
||||
file := filepath.Join(local, test.file)
|
||||
out, err = ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
if want, got := test.text, string(out); want != got {
|
||||
t.Errorf("Want file content %q, got %q", want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTags(t *testing.T) {
|
||||
remote := "/tmp/remote/greeting"
|
||||
|
||||
base, err := ioutil.TempDir("", "test")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
defer os.Remove(base)
|
||||
|
||||
for i, test := range tests {
|
||||
local := filepath.Join(base, fmt.Sprint(i))
|
||||
err = os.MkdirAll(local, 0777)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
bin, err := filepath.Abs("clone-tag")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
cmd := exec.Command(bin)
|
||||
cmd.Dir = local
|
||||
cmd.Env = []string{
|
||||
fmt.Sprintf("DRONE_TAG=%s", test.tag),
|
||||
fmt.Sprintf("DRONE_COMMIT_SHA=%s", test.commit),
|
||||
fmt.Sprintf("DRONE_WORKSPACE=%s", local),
|
||||
fmt.Sprintf("DRONE_REMOTE_URL=%s", remote),
|
||||
}
|
||||
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Log(string(out))
|
||||
return
|
||||
}
|
||||
|
||||
commit, err := getCommit(local)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
if want, got := test.commit, commit; got != want {
|
||||
t.Errorf("Want commit %s, got %s", want, got)
|
||||
}
|
||||
|
||||
file := filepath.Join(local, test.file)
|
||||
out, err = ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
if want, got := test.text, string(out); want != got {
|
||||
t.Errorf("Want file content %q, got %q", want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPullRequest(t *testing.T) {
|
||||
remote := "https://github.com/octocat/Spoon-Knife.git"
|
||||
|
||||
local, err := ioutil.TempDir("", "test")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
defer os.Remove(local)
|
||||
|
||||
bin, err := filepath.Abs("clone-pull-request")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
cmd := exec.Command(bin)
|
||||
cmd.Dir = local
|
||||
cmd.Env = []string{
|
||||
fmt.Sprintf("DRONE_COMMIT_REF=%s", "refs/pull/14596/head"),
|
||||
fmt.Sprintf("DRONE_COMMIT_BRANCH=%s", "main"),
|
||||
fmt.Sprintf("DRONE_COMMIT_SHA=%s", "26923a8f37933ccc23943de0d4ebd53908268582"),
|
||||
fmt.Sprintf("DRONE_WORKSPACE=%s", local),
|
||||
fmt.Sprintf("DRONE_REMOTE_URL=%s", remote),
|
||||
}
|
||||
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Log(string(out))
|
||||
return
|
||||
}
|
||||
|
||||
commit, err := getCommit(local)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
branch, err := getBranch(local)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
if want, got := "26923a8f37933ccc23943de0d4ebd53908268582", commit; got != want {
|
||||
t.Errorf("Want commit %s, got %s", want, got)
|
||||
}
|
||||
|
||||
if want, got := "main", branch; got != want {
|
||||
t.Errorf("Want branch %s, got %s", want, got)
|
||||
}
|
||||
|
||||
file := filepath.Join(local, "directory/file.txt")
|
||||
out, err = ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func getBranch(path string) (string, error) {
|
||||
cmd := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD")
|
||||
cmd.Dir = path
|
||||
out, err := cmd.CombinedOutput()
|
||||
return strings.TrimSpace(string(out)), err
|
||||
}
|
||||
|
||||
func getCommit(path string) (string, error) {
|
||||
cmd := exec.Command("git", "rev-parse", "HEAD")
|
||||
cmd.Dir = path
|
||||
out, err := cmd.CombinedOutput()
|
||||
return strings.TrimSpace(string(out)), err
|
||||
}
|
||||
|
||||
var tests = []struct {
|
||||
branch string
|
||||
commit string
|
||||
tag string
|
||||
file string
|
||||
text string
|
||||
}{
|
||||
{
|
||||
commit: "9cd29dca0a98f76df94d66493ee54788a18190a0",
|
||||
branch: "master",
|
||||
tag: "v1.0.0",
|
||||
file: "hello.txt",
|
||||
text: "hi world\n",
|
||||
},
|
||||
{
|
||||
commit: "bbdf5d4028a6066431f59fcd8d83afff610a55ae",
|
||||
branch: "master",
|
||||
tag: "v1.1.0",
|
||||
file: "hello.txt",
|
||||
text: "hello world\n",
|
||||
},
|
||||
{
|
||||
commit: "553af1ca53c9ad54b096d7ff1416f6c4d1e5049f",
|
||||
branch: "fr",
|
||||
tag: "v2.0.0",
|
||||
file: "hello.txt",
|
||||
text: "salut monde\n",
|
||||
},
|
||||
{
|
||||
commit: "94b4a1710d1581b8b00c5f7b077026eae3c07646",
|
||||
branch: "fr",
|
||||
tag: "v2.1.0",
|
||||
file: "hello.txt",
|
||||
text: "bonjour monde\n",
|
||||
},
|
||||
}
|
33
renovate.json
Normal file
33
renovate.json
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"assignees": [ "volker.raschek" ],
|
||||
"labels": [ "renovate" ],
|
||||
"packageRules": [
|
||||
{
|
||||
"addLabels": [ "renovate/droneci", "renovate/automerge" ],
|
||||
"automerge": true,
|
||||
"matchManagers": "droneci",
|
||||
"matchUpdateTypes": [ "minor", "patch"]
|
||||
},
|
||||
{
|
||||
"description": "Automatically update patch version of used container images in docker files",
|
||||
"addLabels": [ "renovate/container-image", "renovate/automerge" ],
|
||||
"automerge": true,
|
||||
"matchManagers": [ "dockerfile" ],
|
||||
"matchUpdateTypes": [ "patch" ]
|
||||
}
|
||||
],
|
||||
"rebaseLabel": "renovate/rebase",
|
||||
"rebaseWhen": "behind-base-branch",
|
||||
"regexManagers": [
|
||||
{
|
||||
"description": "Update version",
|
||||
"fileMatch": [
|
||||
"^Makefile$"
|
||||
],
|
||||
"matchStrings": [
|
||||
"GOSEC_VERSION\\?=(?<currentValue>.*) # renovate: datasource=(?<datasource>.*) depName=(?<depName>.*)( lookupName=(?<lookupName>.*))?( versioning=(?<versioning>.*))?"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
124
rootfs/usr/local/bin/clone
Executable file
124
rootfs/usr/local/bin/clone
Executable file
@ -0,0 +1,124 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ -n "${DRONE_WORKSPACE}" ]]; then
|
||||
# ensure the unprivileged drone user can write
|
||||
# to the workspace. This is required because
|
||||
# the workspace is a docker volume and is owned
|
||||
# by root.
|
||||
# sudo mkdir -p ${DRONE_WORKSPACE}
|
||||
# sudo chown drone:drone ${DRONE_WORKSPACE}
|
||||
|
||||
# ensure the workspace is the current working
|
||||
# directory. This should already be the case,
|
||||
# but we cd just to be safe.
|
||||
cd "${DRONE_WORKSPACE}" || exit 1
|
||||
fi
|
||||
|
||||
# force the home directory path.
|
||||
|
||||
# if [ "$HOME" != "/home/drone" ]; then
|
||||
# echo "[DEBUG] setting default home directory"
|
||||
# export HOME=/home/drone
|
||||
# fi
|
||||
|
||||
# if the netrc enviornment variables exist, write
|
||||
# the netrc file.
|
||||
|
||||
if [[ -n "${DRONE_NETRC_MACHINE}" ]]; then
|
||||
cat <<EOF > "${HOME}/.netrc"
|
||||
machine ${DRONE_NETRC_MACHINE}
|
||||
login ${DRONE_NETRC_USERNAME}
|
||||
password ${DRONE_NETRC_PASSWORD}
|
||||
EOF
|
||||
fi
|
||||
|
||||
# if the ssh_key environment variable exists, write
|
||||
# the ssh key and add the netrc machine to the
|
||||
# known hosts file.
|
||||
if [[ -n "${DRONE_SSH_KEY}" ]]; then
|
||||
mkdir "${HOME}/.ssh"
|
||||
echo -n "${DRONE_SSH_KEY}" > "${HOME}/.ssh/id_rsa"
|
||||
chmod 600 "${HOME}/.ssh/id_rsa"
|
||||
|
||||
touch "${HOME}/.ssh/known_hosts"
|
||||
chmod 600 "${HOME}/.ssh/known_hosts"
|
||||
ssh-keyscan -H "${DRONE_NETRC_MACHINE}" > /etc/ssh/ssh_known_hosts 2> /dev/null
|
||||
fi
|
||||
|
||||
# # AWS codecommit support using AWS access key & secret key
|
||||
# # Refer: https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-unixes.html
|
||||
|
||||
# if [[ -n "${DRONE_AWS_ACCESS_KEY}" ]]; then
|
||||
# aws configure set aws_access_key_id "${DRONE_AWS_ACCESS_KEY}"
|
||||
# aws configure set aws_secret_access_key "${DRONE_AWS_SECRET_KEY}"
|
||||
# aws configure set default.region "${DRONE_AWS_REGION}"
|
||||
|
||||
# git config --global credential.helper '!aws codecommit credential-helper $@'
|
||||
# git config --global credential.UseHttpPath true
|
||||
# fi
|
||||
|
||||
# configure git global behavior and parameters via the
|
||||
# following environment variables:
|
||||
|
||||
|
||||
if [[ -z "${DRONE_COMMIT_AUTHOR_NAME}" ]]; then
|
||||
export DRONE_COMMIT_AUTHOR_NAME=drone
|
||||
fi
|
||||
|
||||
if [[ -z "${DRONE_COMMIT_AUTHOR_EMAIL}" ]]; then
|
||||
export DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost
|
||||
fi
|
||||
|
||||
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||
export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||
export GIT_COMMITTER_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||
export GIT_COMMITTER_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||
|
||||
# invoke the sub-script based on the drone event type.
|
||||
# TODO we should ultimately look at the ref, since
|
||||
# we need something compatible with deployment events.
|
||||
|
||||
CLONE_TYPE=${DRONE_BUILD_EVENT}
|
||||
case ${DRONE_COMMIT_REF} in
|
||||
refs/tags/*)
|
||||
CLONE_TYPE=tag
|
||||
;;
|
||||
refs/pull/*)
|
||||
CLONE_TYPE=pull_request
|
||||
;;
|
||||
refs/pull-request/*)
|
||||
CLONE_TYPE=pull_request
|
||||
;;
|
||||
refs/merge-requests/*)
|
||||
CLONE_TYPE=pull_request
|
||||
;;
|
||||
esac
|
||||
|
||||
git_clone_retry(){
|
||||
retries="${PLUGIN_RETRIES:-0}"
|
||||
if [ -n "${retries##*[0-9]*}" ] || [ "${retries}" -lt 0 ]; then
|
||||
echo "PLUGIN_RETRIES defined but is not a number: ${retries}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Cloning with ${retries} retries"
|
||||
n=0
|
||||
until [ "$n" -gt "${retries}" ]; do
|
||||
$1 && return
|
||||
n=$((n+1))
|
||||
done
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
case ${CLONE_TYPE} in
|
||||
pull_request)
|
||||
git_clone_retry clone-pull-request
|
||||
;;
|
||||
tag)
|
||||
git_clone_retry clone-tag
|
||||
;;
|
||||
*)
|
||||
git_clone_retry clone-commit
|
||||
;;
|
||||
esac
|
44
rootfs/usr/local/bin/clone-commit
Executable file
44
rootfs/usr/local/bin/clone-commit
Executable file
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
GIT_FETCH_ARGS=""
|
||||
GIT_CHECKOUT_ARGS=""
|
||||
|
||||
if [[ -n "${PLUGIN_DEPTH}" ]]; then
|
||||
GIT_FETCH_ARGS="${GIT_FETCH_ARGS} --depth=${PLUGIN_DEPTH}"
|
||||
fi
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
git remote add origin "${DRONE_REMOTE_URL}"
|
||||
fi
|
||||
|
||||
# the branch may be empty for certain event types,
|
||||
# such as github deployment events. If the branch
|
||||
# is empty we checkout the sha directly. Note that
|
||||
# we intentially omit depth flags to avoid failed
|
||||
# clones due to lack of history.
|
||||
if [[ -z "${DRONE_COMMIT_BRANCH}" ]] && [[ -n "${DRONE_COMMIT_SHA}" ]]; then
|
||||
GIT_CHECKOUT_ARGS="${GIT_CHECKOUT_ARGS} --quiet --force ${DRONE_COMMIT_SHA}"
|
||||
GIT_FETCH_ARGS="${GIT_FETCH_ARGS} origin"
|
||||
fi
|
||||
|
||||
# the commit sha may be empty for builds that are
|
||||
# manually triggered in Harness CI Enterprise. If
|
||||
# the commit is empty we clone the branch.
|
||||
if [[ -n "${DRONE_COMMIT_BRANCH}" ]] && [[ -z "${DRONE_COMMIT_SHA}" ]]; then
|
||||
GIT_CHECKOUT_ARGS="${GIT_CHECKOUT_ARGS} -b ${DRONE_COMMIT_BRANCH} refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
|
||||
GIT_FETCH_ARGS="${GIT_FETCH_ARGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
|
||||
fi
|
||||
|
||||
# if the commit sha and branch name not empty, fetch the branch even if a
|
||||
# fast-forward is not possible. Checkout the specified commit sha which must be
|
||||
# part of the branch.
|
||||
if [[ -n "${DRONE_COMMIT_BRANCH}" ]] && [[ -n "${DRONE_COMMIT_SHA}" ]]; then
|
||||
GIT_CHECKOUT_ARGS="${GIT_CHECKOUT_ARGS} ${DRONE_COMMIT_SHA} -b refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
|
||||
GIT_FETCH_ARGS="${GIT_FETCH_ARGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
|
||||
fi
|
||||
|
||||
git fetch ${GIT_FETCH_ARGS}
|
||||
git checkout ${GIT_CHECKOUT_ARGS}
|
19
rootfs/usr/local/bin/clone-pull-request
Executable file
19
rootfs/usr/local/bin/clone-pull-request
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
FLAGS=""
|
||||
if [[ -n "${PLUGIN_DEPTH}" ]]; then
|
||||
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||
fi
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
git remote add origin "${DRONE_REMOTE_URL}"
|
||||
fi
|
||||
|
||||
git fetch ${FLAGS} origin "+refs/heads/${DRONE_COMMIT_BRANCH}:"
|
||||
git checkout "${DRONE_COMMIT_BRANCH}"
|
||||
|
||||
git fetch origin "${DRONE_COMMIT_REF}:"
|
||||
git merge "${DRONE_COMMIT_SHA}"
|
16
rootfs/usr/local/bin/clone-tag
Executable file
16
rootfs/usr/local/bin/clone-tag
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
FLAGS=""
|
||||
if [[ -n "${PLUGIN_DEPTH}" ]]; then
|
||||
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||
fi
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
git remote add origin "${DRONE_REMOTE_URL}"
|
||||
fi
|
||||
|
||||
git fetch ${FLAGS} origin "+refs/tags/${DRONE_TAG}:"
|
||||
git checkout --quiet --force FETCH_HEAD
|
@ -1,87 +0,0 @@
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var (
|
||||
input stringSlice
|
||||
output string
|
||||
name string
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Var(&input, "input", "input files")
|
||||
flag.StringVar(&output, "output", "", "output file")
|
||||
flag.StringVar(&name, "package", "", "package name")
|
||||
flag.Parse()
|
||||
|
||||
var files []File
|
||||
for _, file := range input {
|
||||
out, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
files = append(files, File{
|
||||
Name: file,
|
||||
Slug: slugify(file),
|
||||
Data: string(out),
|
||||
})
|
||||
}
|
||||
|
||||
data := map[string]interface{}{
|
||||
"Files": files,
|
||||
"Package": name,
|
||||
}
|
||||
buf := new(bytes.Buffer)
|
||||
err := tmpl.Execute(buf, data)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
ioutil.WriteFile(output, buf.Bytes(), 0644)
|
||||
}
|
||||
|
||||
func slugify(s string) string {
|
||||
ext := filepath.Ext(s)
|
||||
s = strings.TrimSuffix(s, ext)
|
||||
s = strings.Title(s)
|
||||
s = strings.ReplaceAll(s, "-", "")
|
||||
s = strings.ReplaceAll(s, "_", "")
|
||||
return s
|
||||
}
|
||||
|
||||
type stringSlice []string
|
||||
|
||||
func (s *stringSlice) String() string {
|
||||
return strings.Join(*s, ",")
|
||||
}
|
||||
|
||||
func (s *stringSlice) Set(value string) error {
|
||||
*s = append(*s, value)
|
||||
return nil
|
||||
}
|
||||
|
||||
type File struct {
|
||||
Name string
|
||||
Data string
|
||||
Slug string
|
||||
}
|
||||
|
||||
var tmpl = template.Must(template.New("_").Parse(`package {{ .Package }}
|
||||
|
||||
// DO NOT EDIT. This file is automatically generated.
|
||||
|
||||
{{ range .Files -}}
|
||||
// Contents of {{ .Name }}
|
||||
const {{ .Slug }} = ` + "`{{ .Data }}`" + `
|
||||
|
||||
{{ end -}}`))
|
@ -1,17 +0,0 @@
|
||||
|
||||
Set-Variable -Name "FLAGS" -Value ""
|
||||
if ($Env:PLUGIN_DEPTH) {
|
||||
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||
}
|
||||
|
||||
if (!(Test-Path .git)) {
|
||||
Write-Host 'git init';
|
||||
git init
|
||||
Write-Host "git remote add origin $Env:DRONE_REMOTE_URL"
|
||||
git remote add origin $Env:DRONE_REMOTE_URL
|
||||
}
|
||||
|
||||
Write-Host "git fetch $FLAGS origin +refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
|
||||
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
|
||||
Write-Host "git checkout $Env:DRONE_COMMIT_SHA -f $Env:DRONE_COMMIT_BRANCH";
|
||||
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH;
|
@ -1,16 +0,0 @@
|
||||
|
||||
Set-Variable -Name "FLAGS" -Value ""
|
||||
if ($Env:PLUGIN_DEPTH) {
|
||||
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||
}
|
||||
|
||||
if (!(Test-Path .git)) {
|
||||
git init
|
||||
git remote add origin $Env:DRONE_REMOTE_URL
|
||||
}
|
||||
|
||||
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:"
|
||||
git checkout $Env:DRONE_COMMIT_BRANCH
|
||||
|
||||
git fetch origin "${Env:DRONE_COMMIT_REF}:"
|
||||
git merge $Env:DRONE_COMMIT_SHA
|
@ -1,13 +0,0 @@
|
||||
|
||||
Set-Variable -Name "FLAGS" -Value ""
|
||||
if ($Env:PLUGIN_DEPTH) {
|
||||
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||
}
|
||||
|
||||
if (!(Test-Path .git)) {
|
||||
git init
|
||||
git remote add origin $Env:DRONE_REMOTE_URL
|
||||
}
|
||||
|
||||
git fetch $FLAGS origin "+refs/tags/${Env:DRONE_TAG}:"
|
||||
git checkout -qf FETCH_HEAD
|
@ -1,64 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop';
|
||||
|
||||
# HACK: no clue how to set the PATH inside the Dockerfile,
|
||||
# so am setting it here instead. This is not idea.
|
||||
$Env:PATH += ';C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin'
|
||||
|
||||
# if the workspace is set we should make sure
|
||||
# it is the current working directory.
|
||||
|
||||
if ($Env:DRONE_WORKSPACE) {
|
||||
cd $Env:DRONE_WORKSPACE
|
||||
}
|
||||
|
||||
# if the netrc enviornment variables exist, write
|
||||
# the netrc file.
|
||||
|
||||
if ($Env:DRONE_NETRC_MACHINE) {
|
||||
@"
|
||||
machine $Env:DRONE_NETRC_MACHINE
|
||||
login $Env:DRONE_NETRC_USERNAME
|
||||
password $Env:DRONE_NETRC_PASSWORD
|
||||
"@ > (Join-Path $Env:USERPROFILE '_netrc');
|
||||
}
|
||||
|
||||
# configure git global behavior and parameters via the
|
||||
# following environment variables:
|
||||
|
||||
if ($Env:PLUGIN_SKIP_VERIFY) {
|
||||
$Env:GIT_SSL_NO_VERIFY = "true"
|
||||
}
|
||||
|
||||
if ($Env:DRONE_COMMIT_AUTHOR_NAME -eq '' -or $Env:DRONE_COMMIT_AUTHOR_NAME -eq $null) {
|
||||
$Env:GIT_AUTHOR_NAME = "drone"
|
||||
} else {
|
||||
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
|
||||
}
|
||||
|
||||
if ($Env:DRONE_COMMIT_AUTHOR_EMAIL -eq '' -or $Env:DRONE_COMMIT_AUTHOR_EMAIL -eq $null) {
|
||||
$Env:GIT_AUTHOR_EMAIL = 'drone@localhost'
|
||||
} else {
|
||||
$Env:GIT_AUTHOR_EMAIL = $Env:DRONE_COMMIT_AUTHOR_EMAIL
|
||||
}
|
||||
|
||||
$Env:GIT_COMMITTER_NAME = $Env:GIT_AUTHOR_NAME
|
||||
$Env:GIT_COMMITTER_EMAIL = $Env:GIT_AUTHOR_EMAIL
|
||||
|
||||
# invoke the sub-script based on the drone event type.
|
||||
# TODO we should ultimately look at the ref, since
|
||||
# we need something compatible with deployment events.
|
||||
|
||||
switch ($Env:DRONE_BUILD_EVENT) {
|
||||
"pull_request" {
|
||||
Invoke-Expression "${PSScriptRoot}\clone-pull-request.ps1"
|
||||
break
|
||||
}
|
||||
"tag" {
|
||||
Invoke-Expression "${PSScriptRoot}\clone-tag.ps1"
|
||||
break
|
||||
}
|
||||
default {
|
||||
Invoke-Expression "${PSScriptRoot}\clone-commit.ps1"
|
||||
break
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
package windows
|
||||
|
||||
//go:generate go run ../scripts/includetext.go --input=clone.ps1 --input=clone-commit.ps1 --input=clone-pull-request.ps1 --input=clone-tag.ps1 --package=windows --output=windows_gen.go
|
@ -1,126 +0,0 @@
|
||||
package windows
|
||||
|
||||
// DO NOT EDIT. This file is automatically generated.
|
||||
|
||||
// Contents of clone.ps1
|
||||
const Clone = `$ErrorActionPreference = 'Stop';
|
||||
|
||||
# HACK: no clue how to set the PATH inside the Dockerfile,
|
||||
# so am setting it here instead. This is not idea.
|
||||
$Env:PATH += ';C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin'
|
||||
|
||||
# if the workspace is set we should make sure
|
||||
# it is the current working directory.
|
||||
|
||||
if ($Env:DRONE_WORKSPACE) {
|
||||
cd $Env:DRONE_WORKSPACE
|
||||
}
|
||||
|
||||
# if the netrc enviornment variables exist, write
|
||||
# the netrc file.
|
||||
|
||||
if ($Env:DRONE_NETRC_MACHINE) {
|
||||
@"
|
||||
machine $Env:DRONE_NETRC_MACHINE
|
||||
login $Env:DRONE_NETRC_USERNAME
|
||||
password $Env:DRONE_NETRC_PASSWORD
|
||||
"@ > (Join-Path $Env:USERPROFILE '_netrc');
|
||||
}
|
||||
|
||||
# configure git global behavior and parameters via the
|
||||
# following environment variables:
|
||||
|
||||
if ($Env:PLUGIN_SKIP_VERIFY) {
|
||||
$Env:GIT_SSL_NO_VERIFY = "true"
|
||||
}
|
||||
|
||||
if ($Env:DRONE_COMMIT_AUTHOR_NAME -eq '' -or $Env:DRONE_COMMIT_AUTHOR_NAME -eq $null) {
|
||||
$Env:GIT_AUTHOR_NAME = "drone"
|
||||
} else {
|
||||
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
|
||||
}
|
||||
|
||||
if ($Env:DRONE_COMMIT_AUTHOR_EMAIL -eq '' -or $Env:DRONE_COMMIT_AUTHOR_EMAIL -eq $null) {
|
||||
$Env:GIT_AUTHOR_EMAIL = 'drone@localhost'
|
||||
} else {
|
||||
$Env:GIT_AUTHOR_EMAIL = $Env:DRONE_COMMIT_AUTHOR_EMAIL
|
||||
}
|
||||
|
||||
$Env:GIT_COMMITTER_NAME = $Env:GIT_AUTHOR_NAME
|
||||
$Env:GIT_COMMITTER_EMAIL = $Env:GIT_AUTHOR_EMAIL
|
||||
|
||||
# invoke the sub-script based on the drone event type.
|
||||
# TODO we should ultimately look at the ref, since
|
||||
# we need something compatible with deployment events.
|
||||
|
||||
switch ($Env:DRONE_BUILD_EVENT) {
|
||||
"pull_request" {
|
||||
Invoke-Expression "${PSScriptRoot}\clone-pull-request.ps1"
|
||||
break
|
||||
}
|
||||
"tag" {
|
||||
Invoke-Expression "${PSScriptRoot}\clone-tag.ps1"
|
||||
break
|
||||
}
|
||||
default {
|
||||
Invoke-Expression "${PSScriptRoot}\clone-commit.ps1"
|
||||
break
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
// Contents of clone-commit.ps1
|
||||
const CloneCommit = `
|
||||
Set-Variable -Name "FLAGS" -Value ""
|
||||
if ($Env:PLUGIN_DEPTH) {
|
||||
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||
}
|
||||
|
||||
if (!(Test-Path .git)) {
|
||||
Write-Host 'git init';
|
||||
git init
|
||||
Write-Host "git remote add origin $Env:DRONE_REMOTE_URL"
|
||||
git remote add origin $Env:DRONE_REMOTE_URL
|
||||
}
|
||||
|
||||
Write-Host "git fetch $FLAGS origin +refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
|
||||
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
|
||||
Write-Host "git checkout $Env:DRONE_COMMIT_SHA -f $Env:DRONE_COMMIT_BRANCH";
|
||||
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH;
|
||||
`
|
||||
|
||||
// Contents of clone-pull-request.ps1
|
||||
const ClonePullRequest = `
|
||||
Set-Variable -Name "FLAGS" -Value ""
|
||||
if ($Env:PLUGIN_DEPTH) {
|
||||
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||
}
|
||||
|
||||
if (!(Test-Path .git)) {
|
||||
git init
|
||||
git remote add origin $Env:DRONE_REMOTE_URL
|
||||
}
|
||||
|
||||
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:"
|
||||
git checkout $Env:DRONE_COMMIT_BRANCH
|
||||
|
||||
git fetch origin "${Env:DRONE_COMMIT_REF}:"
|
||||
git merge $Env:DRONE_COMMIT_SHA
|
||||
`
|
||||
|
||||
// Contents of clone-tag.ps1
|
||||
const CloneTag = `
|
||||
Set-Variable -Name "FLAGS" -Value ""
|
||||
if ($Env:PLUGIN_DEPTH) {
|
||||
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||
}
|
||||
|
||||
if (!(Test-Path .git)) {
|
||||
git init
|
||||
git remote add origin $Env:DRONE_REMOTE_URL
|
||||
}
|
||||
|
||||
git fetch $FLAGS origin "+refs/tags/${Env:DRONE_TAG}:"
|
||||
git checkout -qf FETCH_HEAD
|
||||
`
|
||||
|
Reference in New Issue
Block a user