Skip to content

Commit 791b5f2

Browse files
committed
initial commit
0 parents  commit 791b5f2

18 files changed

+632
-0
lines changed

.drone.yml

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
kind: pipeline
2+
type: docker
3+
name: amd64
4+
5+
platform:
6+
arch: amd64
7+
8+
steps:
9+
- name: build
10+
image: golang
11+
commands:
12+
- go test ./...
13+
- sh scripts/build.sh
14+
15+
- name: publish
16+
image: plugins/docker
17+
settings:
18+
repo: plugins/netlify
19+
auto_tag: true
20+
auto_tag_suffix: linux-amd64
21+
dockerfile: docker/Dockerfile
22+
username:
23+
from_secret: docker_username
24+
password:
25+
from_secret: docker_password
26+
27+
---
28+
kind: pipeline
29+
type: docker
30+
name: arm32
31+
32+
platform:
33+
arch: arm
34+
35+
steps:
36+
- name: build
37+
image: golang
38+
commands:
39+
- go test ./...
40+
- sh scripts/build.sh
41+
42+
- name: publish
43+
image: plugins/docker
44+
settings:
45+
repo: plugins/netlify
46+
auto_tag: true
47+
auto_tag_suffix: linux-arm
48+
dockerfile: docker/Dockerfile.linux.arm
49+
username:
50+
from_secret: docker_username
51+
password:
52+
from_secret: docker_password
53+
54+
---
55+
kind: pipeline
56+
type: docker
57+
name: arm64
58+
59+
platform:
60+
arch: arm64
61+
62+
steps:
63+
- name: build
64+
image: golang
65+
commands:
66+
- go test ./...
67+
- sh scripts/build.sh
68+
69+
- name: publish
70+
image: plugins/docker
71+
settings:
72+
repo: plugins/netlify
73+
auto_tag: true
74+
auto_tag_suffix: linux-arm64
75+
dockerfile: docker/Dockerfile.linux.arm64
76+
username:
77+
from_secret: docker_username
78+
password:
79+
from_secret: docker_password
80+
81+
---
82+
kind: pipeline
83+
type: docker
84+
name: manifest
85+
86+
steps:
87+
- name: manifest
88+
image: plugins/manifest
89+
settings:
90+
spec: docker/manifest.tmpl
91+
auto_tag: true
92+
ignore_missing: true
93+
password:
94+
from_secret: docker_password
95+
username:
96+
from_secret: docker_username
97+
98+
depends_on:
99+
- arm32
100+
- arm64
101+
- amd64

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.env
2+
release/
3+

LICENSE.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Blue Oak Model License
2+
3+
Version 1.0.0
4+
5+
## Purpose
6+
7+
This license gives everyone as much permission to work with
8+
this software as possible, while protecting contributors
9+
from liability.
10+
11+
## Acceptance
12+
13+
In order to receive this license, you must agree to its
14+
rules. The rules of this license are both obligations
15+
under that agreement and conditions to your license.
16+
You must not do anything with this software that triggers
17+
a rule that you cannot or will not follow.
18+
19+
## Copyright
20+
21+
Each contributor licenses you to do everything with this
22+
software that would otherwise infringe that contributor's
23+
copyright in it.
24+
25+
## Notices
26+
27+
You must ensure that everyone who gets a copy of
28+
any part of this software from you, with or without
29+
changes, also gets the text of this license or a link to
30+
<https://blueoakcouncil.org/license/1.0.0>.
31+
32+
## Excuse
33+
34+
If anyone notifies you in writing that you have not
35+
complied with [Notices](#notices), you can keep your
36+
license by taking all practical steps to comply within 30
37+
days after the notice. If you do not do so, your license
38+
ends immediately.
39+
40+
## Patent
41+
42+
Each contributor licenses you to do everything with this
43+
software that would otherwise infringe any patent claims
44+
they can license or become able to license.
45+
46+
## Reliability
47+
48+
No contributor can revoke this license.
49+
50+
## No Liability
51+
52+
***As far as the law allows, this software comes as is,
53+
without any warranty or condition, and no contributor
54+
will be liable to anyone for any damages related to this
55+
software or this license, under any kind of legal claim.***

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Drone plugin for deploying static websites to Netlify. _This plugin is used to publish all static websites for the Drone project, including the official documentation._
2+
3+
# Building
4+
5+
Build the plugin binary:
6+
7+
```text
8+
scripts/build.sh
9+
```
10+
11+
Build the plugin image:
12+
13+
```text
14+
docker build -f docker/Dockerfile -t plugins/netlify .
15+
```
16+
17+
# Testing
18+
19+
Execute the plugin from your current working directory:
20+
21+
```text
22+
docker run --rm \
23+
-e PLUGIN_SITE=3970e0fe-8564-4903-9a55-c5f8de49fb8b \
24+
-e PLUGIN_PATH=./public \
25+
-e PLUGIN_TOKEN=your_oauth2_access_token \
26+
-e PLUGIN_DEBUG=true \
27+
-w /drone/src \
28+
-v $(pwd):/drone/src \
29+
plugins/netlify
30+
```

docker/Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM alpine:3.6 as alpine
2+
RUN apk add -U --no-cache ca-certificates
3+
4+
FROM node:14-alpine
5+
ENV GODEBUG netdns=go
6+
7+
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
8+
9+
RUN npm install netlify-cli -g
10+
11+
ADD release/linux/amd64/plugin /bin/
12+
ENTRYPOINT ["/bin/plugin"]

docker/Dockerfile.linux.arm

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM alpine:3.6 as alpine
2+
RUN apk add -U --no-cache ca-certificates
3+
4+
FROM alpine:3.6
5+
ENV GODEBUG netdns=go
6+
7+
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
8+
9+
ADD release/linux/arm/plugin /bin/
10+
ENTRYPOINT ["/bin/plugin"]

docker/Dockerfile.linux.arm64

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM alpine:3.6 as alpine
2+
RUN apk add -U --no-cache ca-certificates
3+
4+
FROM alpine:3.6
5+
ENV GODEBUG netdns=go
6+
7+
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
8+
9+
ADD release/linux/arm64/plugin /bin/
10+
ENTRYPOINT ["/bin/plugin"]

docker/manifest.tmpl

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
image: plugins/netlify:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
2+
{{#if build.tags}}
3+
tags:
4+
{{#each build.tags}}
5+
- {{this}}
6+
{{/each}}
7+
{{/if}}
8+
manifests:
9+
-
10+
image: plugins/netlify:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
11+
platform:
12+
architecture: amd64
13+
os: linux
14+
-
15+
image: plugins/netlify:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
16+
platform:
17+
variant: v8
18+
architecture: arm64
19+
os: linux
20+
-
21+
image: plugins/netlify:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
22+
platform:
23+
variant: v7
24+
architecture: arm
25+
os: linux
26+
-
27+
image: plugins/netlify:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
28+
platform:
29+
variant: v6
30+
architecture: arm
31+
os: linux

go.mod

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module github.com/drone/drone-netlify
2+
3+
go 1.12
4+
5+
require (
6+
github.com/kelseyhightower/envconfig v1.4.0
7+
github.com/sirupsen/logrus v1.4.2
8+
)

go.sum

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2+
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
3+
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
4+
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
5+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
6+
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
7+
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
8+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
9+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
10+
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
11+
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

main.go

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright 2020 the Drone Authors. All rights reserved.
2+
// Use of this source code is governed by the Blue Oak Model License
3+
// that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"context"
9+
10+
"github.com/drone/drone-netlify/plugin"
11+
12+
"github.com/kelseyhightower/envconfig"
13+
"github.com/sirupsen/logrus"
14+
)
15+
16+
func main() {
17+
logrus.SetFormatter(new(formatter))
18+
19+
var args plugin.Args
20+
if err := envconfig.Process("", &args); err != nil {
21+
logrus.Fatalln(err)
22+
}
23+
24+
switch args.Level {
25+
case "debug":
26+
logrus.SetFormatter(textFormatter)
27+
logrus.SetLevel(logrus.DebugLevel)
28+
case "trace":
29+
logrus.SetFormatter(textFormatter)
30+
logrus.SetLevel(logrus.TraceLevel)
31+
}
32+
33+
if err := plugin.Exec(context.Background(), args); err != nil {
34+
logrus.Fatalln(err)
35+
}
36+
}
37+
38+
// default formatter that writes logs without including timestamp
39+
// or level information.
40+
type formatter struct{}
41+
42+
func (*formatter) Format(entry *logrus.Entry) ([]byte, error) {
43+
return []byte(entry.Message), nil
44+
}
45+
46+
// text formatter that writes logs with level information
47+
var textFormatter = &logrus.TextFormatter{
48+
DisableTimestamp: true,
49+
}

plugin/generate.go

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2020 the Drone Authors. All rights reserved.
2+
// Use of this source code is governed by the Blue Oak Model License
3+
// that can be found in the LICENSE file.
4+
5+
// This program downloads an updated pipeline.go file, which
6+
// provides common pipeline structures and environment variable
7+
// mappings.
8+
9+
// +build ignore
10+
11+
package main
12+
13+
import (
14+
"io/ioutil"
15+
"log"
16+
"net/http"
17+
)
18+
19+
func main() {
20+
res, err := http.Get("https://raw.githubusercontent.com/drone/boilr-plugin/master/template/plugin/pipeline.go")
21+
if res != nil {
22+
defer res.Body.Close()
23+
}
24+
if err != nil {
25+
log.Fatalln(err)
26+
}
27+
28+
data, err := ioutil.ReadAll(res.Body)
29+
if err != nil {
30+
log.Fatalln(err)
31+
}
32+
33+
err = ioutil.WriteFile("pipeline_gen.go", data, 0644)
34+
if err != nil {
35+
log.Fatalln(err)
36+
}
37+
}

plugin/pipeline.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright 2020 the Drone Authors. All rights reserved.
2+
// Use of this source code is governed by the Blue Oak Model License
3+
// that can be found in the LICENSE file.
4+
5+
package plugin
6+
7+
//go:generate go run generate.go

0 commit comments

Comments
 (0)