initial commit
This commit is contained in:
commit
101317a290
|
@ -0,0 +1 @@
|
|||
node_modules
|
|
@ -0,0 +1,19 @@
|
|||
MIT License Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,31 @@
|
|||
# @sigyl/jsonnet-drone
|
||||
|
||||
drone deployment
|
||||
|
||||
## release
|
||||
|
||||
use https://www.conventionalcommits.org/en/v1.0.0/ to control releases.
|
||||
|
||||
to release
|
||||
|
||||
```shell
|
||||
yarn release
|
||||
```
|
||||
|
||||
prerelease
|
||||
|
||||
```shell
|
||||
yarn release --prerelease alpha
|
||||
```
|
||||
|
||||
release as
|
||||
|
||||
```shell
|
||||
yarn release --release-as 1.0.0
|
||||
```
|
||||
|
||||
dry run
|
||||
|
||||
```shell
|
||||
yarn release --dry-run
|
||||
```
|
|
@ -0,0 +1,102 @@
|
|||
local build = import 'lib/build.libsonnet';
|
||||
local images = import 'lib/images.libsonnet';
|
||||
local environment = import 'node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
|
||||
local compose = import 'node_modules/@sigyl/jsonnet-compose/compose.libsonnet';
|
||||
local util = import 'lib/util.libsonnet';
|
||||
|
||||
function(
|
||||
name,
|
||||
root,
|
||||
buildSecrets,
|
||||
publicSecrets,
|
||||
secretSecrets
|
||||
)
|
||||
{
|
||||
kind: 'pipeline',
|
||||
type: 'docker',
|
||||
name: 'deploy',
|
||||
clone: {
|
||||
disable: false,
|
||||
depth: 0,
|
||||
},
|
||||
services: [
|
||||
images.docker {
|
||||
privileged: true,
|
||||
volumes: [
|
||||
{
|
||||
name: 'dockersock',
|
||||
path: '/var/run',
|
||||
},
|
||||
{
|
||||
name: 'ca',
|
||||
path: '/etc/docker/certs.d',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'dockersock',
|
||||
temp: {},
|
||||
},
|
||||
{
|
||||
name: 'ca',
|
||||
host: {
|
||||
path: '/etc/docker/certs.d',
|
||||
},
|
||||
},
|
||||
],
|
||||
steps:[
|
||||
compose(
|
||||
std.map(
|
||||
function(secret) util.printEnv('env-%s' % name, secret),
|
||||
publicSecrets,
|
||||
)
|
||||
)
|
||||
(
|
||||
images.ssh {
|
||||
settings +: {
|
||||
script: [
|
||||
'rm -f env-%s' % name,
|
||||
],
|
||||
},
|
||||
},
|
||||
) {
|
||||
name: 'print env',
|
||||
},
|
||||
images.scp(
|
||||
'%(root)s%(name)s' % { root: root, name: name }
|
||||
),
|
||||
images.wait(15),
|
||||
build(buildSecrets),
|
||||
compose(
|
||||
std.map(
|
||||
function(secret) environment.envSet(secret),
|
||||
publicSecrets + secretSecrets,
|
||||
),
|
||||
)(
|
||||
images.ssh {
|
||||
name: 'deploy',
|
||||
settings +: {
|
||||
script +:
|
||||
std.map(
|
||||
function(secret)
|
||||
'export %(env)s=$${%(env)s}' % {
|
||||
env: environment.environment(secret)
|
||||
},
|
||||
secretSecrets + publicSecrets,
|
||||
) +
|
||||
[
|
||||
'set -e',
|
||||
'cd %(root)s%(name)s' % { root: root, name: name },
|
||||
'sh .drone/login.sh',
|
||||
'sh .drone/pull.sh',
|
||||
'sh .drone/deploy.sh',
|
||||
]
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
local images = import 'images.libsonnet';
|
||||
local environment = import '../node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
|
||||
|
||||
function(secrets)
|
||||
images.docker {
|
||||
name +: 'build:',
|
||||
environment +: environment.environmentSecrets(secrets),
|
||||
volumes: [
|
||||
{
|
||||
name: 'dockersock',
|
||||
path: '/var/run',
|
||||
},
|
||||
],
|
||||
commands: [
|
||||
'set -e',
|
||||
'sh .drone/login.sh',
|
||||
'sh .drone/build.sh',
|
||||
'sh .drone/push.sh',
|
||||
'sh .drone/logout.sh',
|
||||
],
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
local settings = import 'settings.libsonnet';
|
||||
{
|
||||
docker: {
|
||||
name: 'docker',
|
||||
image: 'docker:dind',
|
||||
},
|
||||
scp(target): settings.ssh {
|
||||
name: 'scp',
|
||||
image: 'appleboy/drone-scp:1.6.2',
|
||||
settings +: {
|
||||
command_timeout: '2m',
|
||||
target: target,
|
||||
source: [
|
||||
'.',
|
||||
],
|
||||
},
|
||||
},
|
||||
ssh: settings.ssh {
|
||||
image: 'appleboy/drone-ssh:1.6.2',
|
||||
settings +: {
|
||||
envs: [
|
||||
'drone_tag',
|
||||
'drone_commit',
|
||||
'drone_build_number',
|
||||
'drone_repo_name',
|
||||
'drone_repo_namespace',
|
||||
],
|
||||
script: [],
|
||||
},
|
||||
},
|
||||
wait(delay): {
|
||||
image: 'alpine',
|
||||
name: 'wait',
|
||||
commands: [
|
||||
'sleep %s' % delay,
|
||||
],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
local environment = import '../node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
|
||||
{
|
||||
ssh: {
|
||||
settings +: {
|
||||
host: environment.fromSecret('ssh-host'),
|
||||
port: environment.fromSecret('ssh-port'),
|
||||
username: environment.fromSecret('ssh-user'),
|
||||
key: environment.fromSecret('ssh-key'),
|
||||
},
|
||||
},
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
local compose = import '../node_modules/@sigyl/jsonnet-compose/compose.libsonnet';
|
||||
local environment = import '../node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
|
||||
{
|
||||
printEnv(file, env): function(step) compose([
|
||||
environment.envSet(env),
|
||||
function(step) step {
|
||||
settings +: {
|
||||
script +: [
|
||||
'echo "export %(environment)s=\'$${%(environment)s}\'" >> %(file)s # "%(secret)s"' % {
|
||||
environment: environment.environment(env),
|
||||
file: file,
|
||||
secret: environment.secret(env),
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
])(step),
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"name": "@sigyl/jsonnet-drone",
|
||||
"version": "0.0.1",
|
||||
"description": "jsonnet to build and deploy with drone",
|
||||
"scripts": {
|
||||
"publish": "git push --follow-tags origin master && npm publish",
|
||||
"release": "standard-version",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://sigyl.com/git/sigyl/jsonnet-drone.git"
|
||||
},
|
||||
"keywords": [
|
||||
"jsonnet",
|
||||
"drone"
|
||||
],
|
||||
"author": "giles bradshaw",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"standard-version": "^8.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sigyl/jsonnet-compose": "^0.0.2",
|
||||
"@sigyl/jsonnet-drone-environment": "0.0.5"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue