drone-deploy/README.md

83 lines
1.9 KiB
Markdown
Raw Normal View History

2019-03-05 18:30:10 +00:00
# Drone Deployment Plugin
## Quickstart 🚀
```yaml
kind: pipeline
name: default
steps:
- name: build
image: node:11-alpine
pull: always
commands:
- npm i
- npm run build:prod
- name: deploy
image: cupcakearmy/drone-deploy
pull: always
settings:
host: example.org
user: root
2019-05-25 15:22:52 +00:00
key:
from_secret: ssh_key
2019-05-25 15:29:29 +00:00
# or with a password
# password: S3cr37Sh1zzl3
2019-03-05 18:30:10 +00:00
port: 69
target: /my/web/root/project
sources:
2020-04-13 16:49:01 +00:00
# To copy all the files
# - .
2019-03-05 18:30:10 +00:00
- ./public
- ./docker-compose.yml
- ./docker-compose.prod.yml
commands:
- docker-compose -f docker-compose.yml -f docker-compose.prod.yml down
- docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
when:
event: push
branch: master
```
### Details 📒
The plugins creates a tarball compressing all the files included inside of `sources`.
Then the compressed tarball gets uploaded, extracted and deleted, leaving only the files specified by `sources` inside of the `target` folder.
2019-05-25 15:22:52 +00:00
Afterwards all the commands inside of `commands` will get executed at the `target` directory.
### Mapping remote environment variables 🗺
Sometimes it's usefull to have a remote env with a secret. Here is how.
```yaml
kind: pipeline
name: default
steps:
# build...
- name: deploy
image: cupcakearmy/drone-deploy
pull: always
settings:
# host, user, port, key, when, target ...
2019-05-25 15:26:41 +00:00
myvar: 'Something'
2019-05-25 15:22:52 +00:00
somesecret:
from_secret: mysecret
envs:
- myvar
- somesecret
commands:
- echo $MYENV # Outputs: Something
- echo $SOMESECRET # Outputs: Whatever is saved in drone as `mysecret`
2019-05-25 15:24:42 +00:00
```
###### Note
2019-05-25 15:24:57 +00:00
If you don't want to specify single variables just use `envs: all` and all the parameters inside of `settings` will be available.
2019-05-25 15:24:42 +00:00
All the vars will be automagically be uppercased.