forked from oracle/oci-grafana-metrics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
99 lines (94 loc) · 2.79 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
stages:
- build
- buildgo
- predeploy
- deploy
build:
image: node
stage: build
artifacts:
paths:
- dist/
script:
- npm install
- npm run lint
- npm run test
- npm run buildjs
go:
stage: buildgo
image:
name: golang
dependencies:
- build
artifacts:
paths:
- dist/
script:
- go get -u github.com/golang/dep/cmd/dep
- mkdir -p /go/src/gitlab-odx.oracledx.com/cloudnative/oci-grafana-plugin
- cp -r * /go/src/gitlab-odx.oracledx.com/cloudnative/oci-grafana-plugin/
- cd /go/src/gitlab-odx.oracledx.com/cloudnative/oci-grafana-plugin
- ls -alh
- dep ensure
- go build -o ./oci-plugin_linux_amd64
- GOOS=darwin go build -o ./oci-plugin_darwin_amd64
- GOOS=windows GOARCH=amd64 go build -o ./oci-plugin_windows_amd64.exe
- mv oci-plugin_linux_amd64 /
- mv oci-plugin_darwin_amd64 /
- mv oci-plugin_windows_amd64.exe /
- cd -
- mv /oci-plugin_linux_amd64 dist/
- mv /oci-plugin_darwin_amd64 dist/
- mv /oci-plugin_windows_amd64.exe dist/
- ls dist/
predeploy:
image: node
only:
- master
dependencies:
- build
- go
stage: predeploy
artifacts:
paths:
- dist/
when: manual
script:
- git remote set-url origin https://faiqus:${CI_PUSH_TOKEN}@gitlab-odx.oracledx.com/cloudnative/oci-grafana-plugin.git
- git config --global user.email "[email protected]"
- git config --global user.name "deployboy"
- git fetch
- git checkout master
- git reset --hard origin/master
- npm install
- npm run bump
- cat plugin.json | grep version | cut -d':' -f2 | xargs | cut -d, -f1 >> ./dist/VERSION
deploy:
stage: deploy
only:
- master
image:
name: phx.ocir.io/odx-sre/sauron/gitlab-dind:0.7
entrypoint: ["/bin/sh", "-c"]
dependencies:
- build
- go
- predeploy
when: manual
script:
- VERSION=$(cat ./dist/VERSION)
- rm ./dist/VERSION
- sed 's|"version"':' "\(.*\)"|"version"':' \"'$VERSION'\"|g' -i dist/plugin.json
- tar -cvf plugin.tar dist/
- go get -u github.com/tcnksm/ghr
- rm -rf /root/.oci/config
- mkdir -p /root/.oci
- echo "$OCI_PRIVATE_KEY" | base64 -d >> /root/.oci/oci_api_key.pem
- echo "$OCI_PUBLIC_KEY" | base64 -d >> /root/.oci/oci_api_key_public.pem
- echo "$OCI_CONFIG" | base64 -d >> /root/.oci/config
- oci setup repair-file-permissions --file /root/.oci/oci_api_key.pem
- oci setup repair-file-permissions --file /root/.oci/oci_api_key_public.pem
- oci setup repair-file-permissions --file /root/.oci/config
- oci os object put --force -ns oracle-cloudnative -bn Grafanaplugin --file plugin.tar --name plugin.tar-v$VERSION --no-multipart --content-type tar --no-retry
- export PATH=/go/bin/:$PATH
- ghr -u oracle -r oci-grafana-plugin "v$VERSION" plugin.tar