Compare commits
34 Commits
Author | SHA1 | Date |
---|---|---|
mat ess | c5513a13c3 | |
mat ess | 045f85cd2b | |
mat ess | 0b0dfa9f44 | |
mat ess | 56a6269975 | |
mat ess | 4118f27548 | |
mat ess | d28e4a08bf | |
mat ess | 6e0039f4ac | |
mat ess | 2d42dc1c3a | |
mat ess | f6a9f0128c | |
mat ess | 9a6c3ac24a | |
mat ess | 809c5f10f2 | |
mat ess | 0543638553 | |
mat ess | b20baf7ec6 | |
mat ess | f4179ef114 | |
mat ess | 0a94ba4862 | |
mat ess | 560cb5c81b | |
techknowlogick | 2961c3daf4 | |
techknowlogick | 9e15effeb3 | |
techknowlogick | b1d2c2703c | |
techknowlogick | 492fa7135e | |
techknowlogick | 42903beb0d | |
techknowlogick | 3c3eac0834 | |
techknowlogick | 5f17cccafe | |
Karl Heinz Marbaise | 75b308a52a | |
techknowlogick | d585bba334 | |
techknowlogick | c9ada3a8ee | |
techknowlogick | b14f2c6578 | |
jolheiser | f30bcff0cf | |
jolheiser | ef10f9b285 | |
techknowlogick | c02be20586 | |
techknowlogick | c697d4d5fa | |
techknowlogick | 9e4aa61975 | |
Matti R | 12e8026aa3 | |
Luca Perret | b40ed139b5 |
50
.drone.yml
50
.drone.yml
|
@ -1,8 +1,42 @@
|
|||
pipeline:
|
||||
docker:
|
||||
image: plugins/docker
|
||||
secrets: [ docker_username, docker_password ]
|
||||
repo: lucap/drone-netlify
|
||||
auto_tag: true
|
||||
when:
|
||||
event: tag
|
||||
kind: pipeline
|
||||
name: linux-amd64
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: dryrun
|
||||
pull: always
|
||||
image: plugins/docker:linux-amd64
|
||||
settings:
|
||||
repo: internetmat/drone-netlify
|
||||
tags: latest
|
||||
dry_run: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
||||
|
||||
- name: publish
|
||||
pull: always
|
||||
image: plugins/docker:linux-amd64
|
||||
settings:
|
||||
repo: internetmat/drone-netlify
|
||||
tags: latest
|
||||
force_tag: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
|
|
104
DOCS.md
104
DOCS.md
|
@ -1,104 +1,28 @@
|
|||
---
|
||||
date: 2018-02-15T00:00:00+00:00
|
||||
title: Netlify
|
||||
author: lucaperret
|
||||
author: internetmat
|
||||
tags: [ deploy, netlify ]
|
||||
repo: lucaperret/drone-netlify
|
||||
repo: internetmat/drone-netlify
|
||||
logo: netlify.svg
|
||||
image: lucap/drone-netlify
|
||||
image: internetmat/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:
|
||||
The below pipeline configuration demonstrates the configuration for the plugin.
|
||||
|
||||
```yaml
|
||||
pipeline:
|
||||
netlify:
|
||||
image: lucap/drone-netlify
|
||||
token: xxxxx
|
||||
site_id: xxxxxxx-xxxx-xxx-xxxxxxxx
|
||||
image: internetmat/drone-netlify
|
||||
settings:
|
||||
token:
|
||||
from_secret: netlify_token
|
||||
site:
|
||||
from_secret: netlify_site_id
|
||||
# override deploy alias, defaults to git SHA
|
||||
alias: mybuild
|
||||
path: /site/
|
||||
prod: true
|
||||
```
|
||||
|
||||
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
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
FROM node:alpine
|
||||
FROM node:19-slim
|
||||
|
||||
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 maintainer="internetmat <mat@mat.services>"
|
||||
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
|
||||
|
||||
|
|
23
README.md
23
README.md
|
@ -1,12 +1,10 @@
|
|||
# Drone-netlify
|
||||
# drone-netlify
|
||||
|
||||
![Netlify logo](netlify.png?raw=true "netlify.com")
|
||||
|
||||
> Deploying to [Netlify](https://netlify.com) with [Drone](https://drone.io) CI.
|
||||
|
||||
[![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)
|
||||
[![Docker Pulls](https://img.shields.io/docker/pulls/internetmat/drone-netlify.svg)](https://hub.docker.com/r/internetmat/drone-netlify/)
|
||||
|
||||
Use case examples:
|
||||
|
||||
|
@ -25,12 +23,11 @@ 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
|
||||
-e PLUGIN_TOKEN=$NETLIFY_TOKEN \
|
||||
-e PLUGIN_SITE=my-netlify-site \
|
||||
-v $(pwd):$(pwd) \
|
||||
-w $(pwd) \
|
||||
lucap/drone-netlify
|
||||
internetmat/drone-netlify
|
||||
```
|
||||
|
||||
### From Drone CI
|
||||
|
@ -38,8 +35,10 @@ docker run --rm \
|
|||
```yaml
|
||||
pipeline:
|
||||
netlify:
|
||||
image: lucap/drone-netlify
|
||||
token: xxxxx
|
||||
site_id: xxxxxxx-xxxx-xxx-xxxxxxxx
|
||||
site_name: netlify-subdomain
|
||||
image: internetmat/drone-netlify
|
||||
settings:
|
||||
token:
|
||||
from_secret: netlify_token
|
||||
site:
|
||||
from_secret: netlify_site_id
|
||||
```
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
image: internetmat/drone-netlify:{{#if build.tag}}{{trimPrefix build.tag "v"}}{{else}}latest{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: internetmat/drone-netlify:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
67
script.sh
67
script.sh
|
@ -1,53 +1,62 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
NETLIFY_SITE=""
|
||||
NETLIFY_DEPLOY_OPTIONS=""
|
||||
NETLIFY_UPDATE_OPTIONS=""
|
||||
|
||||
if [ -n "$PLUGIN_ENVIRONMENT" ]
|
||||
if [ -n "$PLUGIN_PROD" ] && [ "$PLUGIN_PROD" != false ]
|
||||
then
|
||||
NETLIFY_DEPLOY_OPTIONS="-e ${PLUGIN_ENVIRONMENT}"
|
||||
NETLIFY_UPDATE_OPTIONS="${NETLIFY_DEPLOY_OPTIONS}"
|
||||
NETLIFY_DEPLOY_OPTIONS="--prod"
|
||||
fi
|
||||
|
||||
if [ -n "$PLUGIN_PATH" ]
|
||||
then
|
||||
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} -p ${PLUGIN_PATH}"
|
||||
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --dir ${PLUGIN_PATH}"
|
||||
else
|
||||
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} -p ./"
|
||||
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --dir ./"
|
||||
fi
|
||||
|
||||
if [ -n "$PLUGIN_SITE_ID" ] && [ -n "$PLUGIN_TOKEN" ]
|
||||
if [ -z "$PLUGIN_TOKEN" ]
|
||||
then
|
||||
NETLIFY_SITE="-t $PLUGIN_TOKEN -s $PLUGIN_SITE_ID"
|
||||
if [ -z "$NETLIFY_TOKEN" ]
|
||||
then
|
||||
echo "> Error! token or netlify_token secret is required"
|
||||
exit 1;
|
||||
else
|
||||
PLUGIN_TOKEN="$NETLIFY_TOKEN"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$PLUGIN_ALIAS" ]
|
||||
then
|
||||
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --alias ${PLUGIN_ALIAS}"
|
||||
elif [ -n "$DRONE_COMMIT_SHA" ]
|
||||
then
|
||||
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --alias ${DRONE_COMMIT_SHA}"
|
||||
fi
|
||||
|
||||
if [ -n "$PLUGIN_DEBUG" ] && [ "$PLUGIN_DEBUG" != false ]
|
||||
then
|
||||
cat netlify.toml
|
||||
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --debug"
|
||||
fi
|
||||
|
||||
if [ -n "$PLUGIN_SITE" ]
|
||||
then
|
||||
NETLIFY_SITE="--auth $PLUGIN_TOKEN --site $PLUGIN_SITE"
|
||||
echo "> Deploying on Netlify…" &&
|
||||
netlify $NETLIFY_SITE deploy $NETLIFY_DEPLOY_OPTIONS;
|
||||
echo "> (Using option $NETLIFY_DEPLOY_OPTIONS)" &&
|
||||
netlify deploy $NETLIFY_SITE $NETLIFY_DEPLOY_OPTIONS --message "$DRONE_COMMIT_MESSAGE";
|
||||
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;
|
||||
echo "> Error! site (site ID or name) and token are required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rc=$?;
|
||||
if [[ $rc != 0 ]];
|
||||
if [[ $rc != 0 ]]
|
||||
then
|
||||
echo "> non-zero exit code $rc" &&
|
||||
exit $rc
|
||||
else
|
||||
echo $'\n'"> Successfully deployed!"$'\n'
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue