docker_practice/cases/ci/drone/README.md

100 lines
2.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Drone
`Docker` `CI/CD` `Drone` `Docker`
`.drone.yml` git `Drone`
`GitHub` + `Drone` `Drone` GitHub 使 `Gogs` + `Drone` `CI/CD`
## Drone
Github `drone-demo`
[ Drone ](install.md) [Drone Cloud](https://cloud.drone.io),使用 GitHub 账号登录,在界面中关联刚刚新建的 `drone-demo` 仓库。
##
git
```bash
$ mkdir drone-demo
$ cd drone-demo
$ git init
$ git remote add origin git@github.com:username/drone-demo.git
```
`Go` `Hello World!`
`app.go`
```go
package main
import "fmt"
func main(){
fmt.Printf("Hello World!\n");
}
```
`.drone.yml`
```yaml
kind: pipeline
type: docker
name: build
steps:
- name: build
image: golang:alpine
pull: if-not-exists # always never
environment:
KEY: VALUE
commands:
- echo $KEY
- pwd
- ls
- CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
- ./app
trigger:
branch:
- master
```
```bash
.
├── .drone.yml
└── app.go
```
## GitHub
```bash
$ git add .
$ git commit -m "test drone ci"
$ git push origin master
```
##
`Drone` Drone Cloud
![](_images/drone-build.png)
GitHubDocker Registry
GitBook 使 Drone CI/CD [`.drone.yml`](https://github.com/yeasy/docker_practice/blob/master/.drone.yml) 文件。
##
* [Drone Github](https://github.com/drone/drone)
* [Drone ](https://docs.drone.io/)
* [Drone ](https://github.com/docker-practice/drone-demo)