From af8d7a3caa77d7476d8551cc5c0c944d31285493 Mon Sep 17 00:00:00 2001 From: Giles Bradshaw Date: Thu, 27 Aug 2020 00:14:17 +0100 Subject: [PATCH] fix: chnaged to jsonnet for build --- .drone/build.sh | 1 + deploy.sh => .drone/deploy.sh | 0 .drone/drone-home.jsonnet | 17 +++ .drone/drone-home.yml | 184 ++++++++++++++++++++++++++++ .drone/lib/public-secrets.libsonnet | 6 + .drone/lib/secret-secrets.libsonnet | 5 + .drone/login.sh | 1 + .drone/logout.sh | 1 + .drone/package.json | 9 ++ .drone/pull.sh | 1 + .drone/push.sh | 1 + .drone/yarn.lock | 21 ++++ CHANGELOG.md | 6 + docker-compose.yml | 4 +- git-hooks/pre-commit | 3 + package.json | 2 +- 16 files changed, 259 insertions(+), 3 deletions(-) create mode 100644 .drone/build.sh rename deploy.sh => .drone/deploy.sh (100%) create mode 100644 .drone/drone-home.jsonnet create mode 100644 .drone/drone-home.yml create mode 100644 .drone/lib/public-secrets.libsonnet create mode 100644 .drone/lib/secret-secrets.libsonnet create mode 100644 .drone/login.sh create mode 100644 .drone/logout.sh create mode 100644 .drone/package.json create mode 100644 .drone/pull.sh create mode 100644 .drone/push.sh create mode 100644 .drone/yarn.lock create mode 100755 git-hooks/pre-commit diff --git a/.drone/build.sh b/.drone/build.sh new file mode 100644 index 0000000..2a63ff4 --- /dev/null +++ b/.drone/build.sh @@ -0,0 +1 @@ +docker build drone-starlark -t ${LOCAL_DOCKER_REGISTRY}drone-starlark diff --git a/deploy.sh b/.drone/deploy.sh similarity index 100% rename from deploy.sh rename to .drone/deploy.sh diff --git a/.drone/drone-home.jsonnet b/.drone/drone-home.jsonnet new file mode 100644 index 0000000..c9c248f --- /dev/null +++ b/.drone/drone-home.jsonnet @@ -0,0 +1,17 @@ + +local secretSecrets = import 'lib/secret-secrets.libsonnet'; +local publicSecrets = import 'lib/public-secrets.libsonnet'; + +local deploy = import 'node_modules/@sigyl/jsonnet-drone/deploy.libsonnet'; +[ + deploy( + 'drone', + '/stack/', + [ + 'LOCAL_DOCKER_REGISTRY', + 'REGISTRY_PASSWORD', + ], + publicSecrets, + secretSecrets + ), +] diff --git a/.drone/drone-home.yml b/.drone/drone-home.yml new file mode 100644 index 0000000..9c68fd1 --- /dev/null +++ b/.drone/drone-home.yml @@ -0,0 +1,184 @@ +--- +kind: pipeline +type: docker +name: deploy + +platform: + os: linux + arch: amd64 + +steps: +- name: print env + image: appleboy/drone-ssh:1.6.2 + settings: + envs: + - drone_tag + - drone_commit + - drone_build_number + - drone_repo_name + - drone_repo_namespace + - local_docker_registry + - registry_password + - drone_domain + - drone_gitea_client_id + - drone_gitea_server + - drone_server_host + - drone_convert_secret + - drone_gitea_client_secret + - drone_rpc_secret + host: + from_secret: ssh-host + key: + from_secret: ssh-key + port: + from_secret: ssh-port + script: + - rm -f env-drone + - "echo \"export LOCAL_DOCKER_REGISTRY='$${LOCAL_DOCKER_REGISTRY}'\" >> env-drone # \"local-docker-registry\"" + - "echo \"export REGISTRY_PASSWORD='$${REGISTRY_PASSWORD}'\" >> env-drone # \"registry-password\"" + - "echo \"export DRONE_DOMAIN='$${DRONE_DOMAIN}'\" >> env-drone # \"drone-domain\"" + - "echo \"export DRONE_GITEA_CLIENT_ID='$${DRONE_GITEA_CLIENT_ID}'\" >> env-drone # \"drone-gitea-client-id\"" + - "echo \"export DRONE_GITEA_SERVER='$${DRONE_GITEA_SERVER}'\" >> env-drone # \"drone-gitea-server\"" + - "echo \"export DRONE_SERVER_HOST='$${DRONE_SERVER_HOST}'\" >> env-drone # \"drone-server-host\"" + - "echo \"export DRONE_CONVERT_SECRET='$${DRONE_CONVERT_SECRET}'\" >> env-drone # \"drone-convert-secret\"" + - "echo \"export DRONE_GITEA_CLIENT_SECRET='$${DRONE_GITEA_CLIENT_SECRET}'\" >> env-drone # \"drone-gitea-client-secret\"" + - "echo \"export DRONE_RPC_SECRET='$${DRONE_RPC_SECRET}'\" >> env-drone # \"drone-rpc-secret\"" + username: + from_secret: ssh-user + environment: + DRONE_CONVERT_SECRET: + from_secret: drone-convert-secret + DRONE_DOMAIN: + from_secret: drone-domain + DRONE_GITEA_CLIENT_ID: + from_secret: drone-gitea-client-id + DRONE_GITEA_CLIENT_SECRET: + from_secret: drone-gitea-client-secret + DRONE_GITEA_SERVER: + from_secret: drone-gitea-server + DRONE_RPC_SECRET: + from_secret: drone-rpc-secret + DRONE_SERVER_HOST: + from_secret: drone-server-host + LOCAL_DOCKER_REGISTRY: + from_secret: local-docker-registry + REGISTRY_PASSWORD: + from_secret: registry-password + +- name: scp + image: appleboy/drone-scp:1.6.2 + settings: + command_timeout: 2m + host: + from_secret: ssh-host + key: + from_secret: ssh-key + port: + from_secret: ssh-port + source: + - . + target: /stack/drone + username: + from_secret: ssh-user + +- name: wait + image: alpine + commands: + - sleep 15 + +- name: "dockerbuild:" + image: docker:dind + commands: + - set -e + - sh .drone/login.sh + - sh .drone/build.sh + - sh .drone/push.sh + - sh .drone/logout.sh + environment: + LOCAL_DOCKER_REGISTRY: + from_secret: local-docker-registry + REGISTRY_PASSWORD: + from_secret: registry-password + volumes: + - name: dockersock + path: /var/run + +- name: deploy + image: appleboy/drone-ssh:1.6.2 + settings: + envs: + - drone_tag + - drone_commit + - drone_build_number + - drone_repo_name + - drone_repo_namespace + - drone_domain + - drone_gitea_client_id + - drone_gitea_server + - drone_server_host + - drone_convert_secret + - drone_gitea_client_secret + - drone_rpc_secret + - local_docker_registry + - registry_password + host: + from_secret: ssh-host + key: + from_secret: ssh-key + port: + from_secret: ssh-port + script: + - export DRONE_CONVERT_SECRET=$${DRONE_CONVERT_SECRET} + - export DRONE_GITEA_CLIENT_SECRET=$${DRONE_GITEA_CLIENT_SECRET} + - export DRONE_RPC_SECRET=$${DRONE_RPC_SECRET} + - export DRONE_DOMAIN=$${DRONE_DOMAIN} + - export DRONE_GITEA_CLIENT_ID=$${DRONE_GITEA_CLIENT_ID} + - export DRONE_GITEA_SERVER=$${DRONE_GITEA_SERVER} + - export DRONE_SERVER_HOST=$${DRONE_SERVER_HOST} + - export LOCAL_DOCKER_REGISTRY=$${LOCAL_DOCKER_REGISTRY} + - export REGISTRY_PASSWORD=$${REGISTRY_PASSWORD} + - set -e + - cd /stack/drone + - sh .drone/login.sh + - sh .drone/pull.sh + - sh .drone/deploy.sh + username: + from_secret: ssh-user + environment: + DRONE_CONVERT_SECRET: + from_secret: drone-convert-secret + DRONE_DOMAIN: + from_secret: drone-domain + DRONE_GITEA_CLIENT_ID: + from_secret: drone-gitea-client-id + DRONE_GITEA_CLIENT_SECRET: + from_secret: drone-gitea-client-secret + DRONE_GITEA_SERVER: + from_secret: drone-gitea-server + DRONE_RPC_SECRET: + from_secret: drone-rpc-secret + DRONE_SERVER_HOST: + from_secret: drone-server-host + LOCAL_DOCKER_REGISTRY: + from_secret: local-docker-registry + REGISTRY_PASSWORD: + from_secret: registry-password + +services: +- name: docker + image: docker:dind + 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 + +... diff --git a/.drone/lib/public-secrets.libsonnet b/.drone/lib/public-secrets.libsonnet new file mode 100644 index 0000000..cd205e0 --- /dev/null +++ b/.drone/lib/public-secrets.libsonnet @@ -0,0 +1,6 @@ +[ + 'drone-domain', + 'drone-gitea-client-id', + 'drone-gitea-server', + 'drone-server-host', +] diff --git a/.drone/lib/secret-secrets.libsonnet b/.drone/lib/secret-secrets.libsonnet new file mode 100644 index 0000000..90b84ad --- /dev/null +++ b/.drone/lib/secret-secrets.libsonnet @@ -0,0 +1,5 @@ +[ + 'drone-convert-secret', + 'drone-gitea-client-secret', + 'drone-rpc-secret', +] diff --git a/.drone/login.sh b/.drone/login.sh new file mode 100644 index 0000000..c8ffffc --- /dev/null +++ b/.drone/login.sh @@ -0,0 +1 @@ +docker login ${LOCAL_DOCKER_REGISTRY} --username client --password "${REGISTRY_PASSWORD}" \ No newline at end of file diff --git a/.drone/logout.sh b/.drone/logout.sh new file mode 100644 index 0000000..4bcacf0 --- /dev/null +++ b/.drone/logout.sh @@ -0,0 +1 @@ +docker logout ${LOCAL_DOCKER_REGISTRY} \ No newline at end of file diff --git a/.drone/package.json b/.drone/package.json new file mode 100644 index 0000000..45387ae --- /dev/null +++ b/.drone/package.json @@ -0,0 +1,9 @@ +{ + "private": true, + "scripts": { + "build": "drone jsonnet --source drone-home.jsonnet --target drone-home.yml --stream" + }, + "dependencies": { + "@sigyl/jsonnet-drone": "^0.0.7" + } +} diff --git a/.drone/pull.sh b/.drone/pull.sh new file mode 100644 index 0000000..2a63ff4 --- /dev/null +++ b/.drone/pull.sh @@ -0,0 +1 @@ +docker build drone-starlark -t ${LOCAL_DOCKER_REGISTRY}drone-starlark diff --git a/.drone/push.sh b/.drone/push.sh new file mode 100644 index 0000000..a8b625c --- /dev/null +++ b/.drone/push.sh @@ -0,0 +1 @@ +docker push ${LOCAL_DOCKER_REGISTRY}drone-starlark diff --git a/.drone/yarn.lock b/.drone/yarn.lock new file mode 100644 index 0000000..b97ecd6 --- /dev/null +++ b/.drone/yarn.lock @@ -0,0 +1,21 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@sigyl/jsonnet-compose@^0.0.2": + version "0.0.2" + resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-compose/-/jsonnet-compose-0.0.2.tgz#8900a21e8cd8109929b6042703f8645aacb9bcda" + integrity sha512-wWS3CgPeNi/o1pcS6n/4pafxlMD0KC9/RKMZr/ySmzeGNRW++sPuKuxajYse2TNd47uNDdeUSnk4aEeEIKL0zA== + +"@sigyl/jsonnet-drone-environment@0.0.5": + version "0.0.5" + resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone-environment/-/jsonnet-drone-environment-0.0.5.tgz#9ea85e08904777bd21a3e4b30b0b91461d0285ff" + integrity sha512-xVGmdMO1pOyozAWUbJm6mzKBgsLPJ+1hWnGCK3AxPkr7kkDh18hu30+TLzlcQtqq76s5jUfvJUztezsGj/mIcw== + +"@sigyl/jsonnet-drone@^0.0.7": + version "0.0.7" + resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone/-/jsonnet-drone-0.0.7.tgz#0f92ef15096b0c5497741ff56bfbd249de9edd66" + integrity sha512-353n/zExNnKPPZ235eLX3/DFXJVNIX8fdAeG3RvY+55538eGzDIk0/3HJd8jXsD6y0zxm+LexW5HghvXBMBOEA== + dependencies: + "@sigyl/jsonnet-compose" "^0.0.2" + "@sigyl/jsonnet-drone-environment" "0.0.5" diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cea95b..e54a64f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,4 +2,10 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [0.0.4](https://sigyl.com///compare/v0.0.3...v0.0.4) "chore(release): 0.0.4" (2020-08-19) + +### [0.0.3](https://sigyl.com///compare/v0.0.2...v0.0.3) "chore(release): 0.0.3" (2020-08-19) + +### [0.0.2](https://sigyl.com///compare/v0.0.1...v0.0.2) "chore(release): 0.0.2" (2020-08-19) + ### 0.0.1 "chore(release): 0.0.1" (2020-08-11) diff --git a/docker-compose.yml b/docker-compose.yml index 52b0ab1..b70ddac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: replicas: 1 restart_policy: condition: any - image: drone/drone:1.7.0 + image: drone/drone:1.9.0 volumes: - drone:/var/lib/drone - drone-data:/data @@ -39,7 +39,7 @@ services: replicas: 1 restart_policy: condition: any - image: drone/drone-runner-docker:1 + image: drone/drone-runner-docker:1.5.0 volumes: - /var/run/docker.sock:/var/run/docker.sock environment: diff --git a/git-hooks/pre-commit b/git-hooks/pre-commit new file mode 100755 index 0000000..7161ae2 --- /dev/null +++ b/git-hooks/pre-commit @@ -0,0 +1,3 @@ +drone jsonnet --source .drone/drone-home.jsonnet --target .drone/drone-home.yml --stream \ +&& git add .drone/drone-home.yml \ +&& echo "jsonnet built" \ No newline at end of file diff --git a/package.json b/package.json index 777bd1f..ad1722d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "drone", - "version": "0.0.1", + "version": "0.0.4", "description": "drone ci", "scripts": { "deploy": "sh deploy.sh",