Skip to content

Commit 5a00a6b

Browse files
committed
Update CI
* Update drone to v1.x * Add GitHub Actions
1 parent 8a3be46 commit 5a00a6b

20 files changed

+324
-258
lines changed

.drone.yml

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
workspace:
2-
base: /srv/gitbook-src
3-
path: .
4-
pipeline:
5-
build:
6-
image: yeasy/docker_practice:latest
7-
# pull: true
8-
environment:
9-
- TZ=Asia/Shanghai
10-
secrets: [key1, key2]
11-
commands:
12-
# - echo $${key1}
13-
# - echo $KEY2
14-
- docker-entrypoint.sh build
15-
when:
16-
event: [push, pull_request, tag, deployment]
17-
branch: master
1+
kind: pipeline
2+
type: docker
3+
name: build
4+
steps:
5+
- name: build
6+
image: yeasy/docker_practice:latest
7+
pull: if-not-exists # always never
8+
environment:
9+
TZ: Asia/Shanghai
10+
commands:
11+
- docker-entrypoint.sh build
12+
13+
trigger:
14+
branch:
15+
- master

.github/workflows/ci.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on:
2+
push:
3+
pull_request:
4+
5+
name: CI
6+
7+
jobs:
8+
build:
9+
name: Build GitBook
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@master
13+
with:
14+
fetch-depth: 2
15+
- name: Build
16+
uses: docker://yeasy/docker_practice
17+
with:
18+
args: build

.travis/docker-entrypoint.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ if [ $1 = "sh" ];then sh ; exit 0; fi
66

77
rm -rf node_modules _book
88

9-
cp -a . ../gitbook
9+
srcDir=$PWD
1010

11-
cd ../gitbook
11+
cp -a . /srv/gitbook
12+
13+
cd /srv/gitbook
1214

1315
main(){
14-
if [ "$1" = build ];then gitbook build; cp -a _book ../gitbook-src; echo $START; date "+%F %T"; exit 0; fi
16+
if [ "$1" = build ];then gitbook build; cp -a _book $srcDir; echo $START; date "+%F %T"; exit 0; fi
1517
exec gitbook serve
1618
exit 0
1719
}

SUMMARY.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,10 @@
144144
* [CentOS Fedora](cases/os/centos.md)
145145
* [本章小结](cases/os/summary.md)
146146
* [实战案例-CI/CD](cases/ci/README.md)
147-
* [Drone](cases/ci/drone.md)
148-
* [Travis CI](cases/ci/travis.md)
147+
* [GitHub Actions](cases/ci/actions/README.md)
148+
* [Drone](cases/ci/drone/README.md)
149+
* [部署 Drone](cases/ci/drone/install.md)
150+
* [Travis CI](cases/ci/travis/README.md)
149151
* [Docker 开源项目](opensource/README.md)
150152
* [LinuxKit](opensource/linuxkit.md)
151153
* [附录](appendix/README.md)

cases/.image/drone-github.png

-85.7 KB
Binary file not shown.

cases/ci/actions/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# GitHub Actions
2+
3+
GitGub Actions 是 GitHub 推出的一款 CI/CD 工具。
4+
5+
我们可以在每个 job 的 step 中使用 Docker 执行构建步骤。
6+
7+
```yaml
8+
on: push
9+
10+
name: CI
11+
12+
jobs:
13+
my-job:
14+
name: Build
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@master
18+
with:
19+
fetch-depth: 2
20+
- name: run docker container
21+
uses: docker://golang:alpine
22+
with:
23+
args: go version
24+
```
25+
26+
## 参考资料
27+
28+
* [Actions Docs](https://help.github.com/en/categories/automating-your-workflow-with-github-actions)

cases/ci/demo/drone/.drone.yml

-17
This file was deleted.

cases/ci/demo/drone/docker-compose.yml

-35
This file was deleted.

cases/ci/drone.md

-183
This file was deleted.

cases/ci/drone/.env.example

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DRONE_SERVER_HOST=
2+
DRONE_SERVER_PROTO=
3+
DRONE_RPC_SECRET=
4+
HOSTNAME=
5+
DRONE_GITHUB_CLIENT_ID=
6+
DRONE_GITHUB_CLIENT_SECRET=

cases/ci/drone/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env
2+
ssl/*

0 commit comments

Comments
 (0)