pull/1/head v0.1.0
Luca Perret 2018-02-15 21:08:23 +01:00
parent bfebdd8a64
commit 6cf7040471
8 changed files with 257 additions and 1 deletions

8
.drone.yml Normal file
View File

@ -0,0 +1,8 @@
pipeline:
docker:
image: plugins/docker
secrets: [ docker_username, docker_password ]
repo: lucap/drone-netlify
auto_tag: true
when:
event: tag

104
DOCS.md Normal file
View File

@ -0,0 +1,104 @@
---
date: 2018-02-15T00:00:00+00:00
title: Netlify
author: lucaperret
tags: [ deploy, netlify ]
repo: lucaperret/drone-netlify
logo: netlify.svg
image: lucap/drone-netlify
---
The netlify plugin deploy your build to [netlify.com](https://netlify.com).
The below pipeline configuration demonstrates simple usage to deploy the current working directory:
```yaml
pipeline:
netlify:
image: lucap/drone-netlify
token: xxxxx
site_id: xxxxxxx-xxxx-xxx-xxxxxxxx
```
Example configuration for assigning [Netlify subdomain](https://www.netlify.com/docs/custom-domains/):
```diff
pipeline:
netlify:
image: lucap/drone-netlify
token: xxxxx
site_id: xxxxxxx-xxxx-xxx-xxxxxxxx
+ site_name: my-deployment-alias
```
Example configuration with [Custom domain](https://www.netlify.com/docs/custom-domains/):
```diff
pipeline:
netlify:
image: lucap/drone-netlify
token: xxxxx
site_id: xxxxxxx-xxxx-xxx-xxxxxxxx
- site_name: my-deployment-alias
+ domain: my-custom-domain.com
```
Example configuration for specifying [environment](https://www.netlify.com/docs/continuous-deployment/#deploy-contexts):
```diff
pipeline:
netlify:
image: lucap/drone-netlify
token: xxxxx
site_id: xxxxxxx-xxxx-xxx-xxxxxxxx
- domain: my-custom-domain.com
+ environment: production
```
Example configuration to deploy a specific folder or Zip (default current working directory):
```diff
pipeline:
netlify:
image: lucap/drone-netlify
token: xxxxx
site_id: xxxxxxx-xxxx-xxx-xxxxxxxx
- environment: production
+ path: ./dist
```
Example configuration using token from secrets:
```diff
pipeline:
netlify:
image: lucap/drone-netlify
- token: xxxxx
site_id: xxxxxxx-xxxx-xxx-xxxxxxxx
+ secrets: [ netlify_token ]
```
# Secret Reference
netlify_token
: Netlify [token](https://app.netlify.com/applications)
# Parameter Reference
token
: `Required` Netlify [token](https://app.netlify.com/applications)
site_id
: `Required` Set the Site ID (or API ID in your Site settings dashboard)
site_name
: Set a Netlify subdomain
domain
: Set your custom domain
environment
: Specify an environment
path
: Path to a folder or zip file to deploy

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM node:alpine
LABEL maintainer="Luca Perret <perret.luca@gmail.com>"
LABEL org.label-schema.version=latest
LABEL org.label-schema.vcs-url="https://github.com/lucaperret/drone-netlify"
LABEL org.label-schema.name="drone-netlify"
LABEL org.label-schema.description="Deploying to netlify with Drone CI"
LABEL org.label-schema.vendor="Luca Perret"
LABEL org.label-schema.schema-version="1.0"
RUN npm install -g netlify-cli
ADD script.sh /bin/
RUN chmod +x /bin/script.sh
ENTRYPOINT /bin/script.sh

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2018 Luca Copyright (c) 2018 Luca Perret
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

45
README.md Normal file
View File

@ -0,0 +1,45 @@
# Drone-netlify
![Netlify logo](netlify.png?raw=true "netlify.com")
[![Docker Pulls](https://img.shields.io/docker/pulls/lucap/drone-netlify.svg)](https://hub.docker.com/r/lucap/drone-netlify/)
[![Image](https://images.microbadger.com/badges/image/lucap/drone-netlify.svg)](https://microbadger.com/images/lucap/drone-netlify "Get your own image badge on microbadger.com")
[![GitHub release](https://img.shields.io/github/release/lucaperret/drone-netlify.svg)](https://github.com/lucaperret/drone-netlify/releases/latest)
Deploying to [Netlify](https://netlify.com) with [Drone](https://drone.io) CI.
Use case examples:
- Automatically create staging deployments for pull requests
- Automatically deploy and alias upon pushes to master
## Usage
For the usage information and a listing of the available options please take a look at [the docs](DOCS.md).
There are two ways to deploy.
### From docker
Deploy the working directory to Netlify.
```bash
docker run --rm \
-e PLUGIN_TOKEN=xxxxx \
-e PLUGIN_SITE_ID=xxxxxxx-xxxx-xxx-xxxxxxxx \
-e PLUGIN_SITE_NAME=netlify-subdomain
-v $(pwd):$(pwd) \
-w $(pwd) \
lucap/drone-netlify
```
### From Drone CI
```yaml
pipeline:
netlify:
image: lucap/drone-netlify
token: xxxxx
site_id: xxxxxxx-xxxx-xxx-xxxxxxxx
site_name: netlify-subdomain
```

BIN
netlify.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

37
netlify.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 11 KiB

46
script.sh Executable file
View File

@ -0,0 +1,46 @@
#!/bin/sh
set -e
NETLIFY_SITE=""
NETLIFY_DEPLOY_OPTIONS=""
NETLIFY_UPDATE_OPTIONS=""
if [ -n "$PLUGIN_ENVIRONMENT" ]
then
NETLIFY_DEPLOY_OPTIONS="-e ${PLUGIN_ENVIRONMENT}"
NETLIFY_UPDATE_OPTIONS="${NETLIFY_DEPLOY_OPTIONS}"
fi
if [ -n "$PLUGIN_PATH" ]
then
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} -p ${PLUGIN_PATH}"
else
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} -p ./"
fi
if [ -n "$PLUGIN_SITE_ID" ] && [ -n "$PLUGIN_TOKEN" ]
then
NETLIFY_SITE="-t $PLUGIN_TOKEN -s $PLUGIN_SITE_ID"
echo "> Deploying on Netlify…" &&
netlify $NETLIFY_SITE deploy $NETLIFY_DEPLOY_OPTIONS;
else
echo "> Error! site_id and token are required"
fi
if [ -n "$PLUGIN_SITE_NAME" ]
then
NETLIFY_UPDATE_OPTIONS="${NETLIFY_UPDATE_OPTIONS} -n ${PLUGIN_SITE_NAME}"
fi
if [ -n "$PLUGIN_DOMAIN" ]
then
NETLIFY_UPDATE_OPTIONS="${NETLIFY_UPDATE_OPTIONS} -d ${PLUGIN_DOMAIN}"
fi
if [ -n "$PLUGIN_SITE_NAME" ] || [ -n "$PLUGIN_DOMAIN" ]
then
echo "> Updating your Netlify site…" &&
netlify $NETLIFY_SITE update $NETLIFY_UPDATE_OPTIONS;
fi
echo $'\n'"> Successfully deployed!"$'\n'