-
Notifications
You must be signed in to change notification settings - Fork 2
/
wercker.yml
89 lines (77 loc) · 3.6 KB
/
wercker.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
box: ruby:2.5.1
# Run weseek/growi, mongo, elasticsearch
services:
- name: mongo
id: mongo:3.4
build:
# Steps make up the actions in your pipeline
# Read more about steps on our dev center:
# http://devcenter.wercker.com/docs/steps/index.html
steps:
- bundle-install
- script:
name: "Install utility tools"
code: |
apt-get update
apt-get install -y netcat
- script:
name: "Wait for MongoDB connection"
code: |
echo Wait for connect to $MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT
while ! nc -q 1 $MONGO_PORT_27017_TCP_ADDR $MONGO_PORT_27017_TCP_PORT </dev/null; do
echo "...waiting 3s"; sleep 3;
done
- internal/docker-run:
image: weseek/growi:3.1.12
name: growi
env: >
MONGO_URI=mongodb://$MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT/growi
PASSWORD_SEED=empty
FILE_UPLOAD=local
- script:
name: "Wait for GROWI connection"
code: |
echo Wait for connect to growi:3000
while ! nc -q 1 growi 3000 < /dev/null; do
echo "...waiting 3s"; sleep 3;
done
export GROWI_URL=http://growi:3000
- script:
name: "Create admin user"
code: |
export ADMIN_USER_NAME=admin1
export ADMIN_USER_PASS=admin1pass
LOGIN_COOKIE=login.cookie
OUTPUT_PAGE_NAME=installer.html
curl $GROWI_URL/installer -c ${LOGIN_COOKIE} -o ${OUTPUT_PAGE_NAME}
CSRF=`grep data-csrftoken ${OUTPUT_PAGE_NAME} | awk -F'=' '{ print $2 }' | sed -e s/\"//g`
curl $GROWI_URL/installer/createAdmin -b ${LOGIN_COOKIE} -X POST \
-d "registerForm[name]=${ADMIN_USER_NAME}®isterForm[username]=${ADMIN_USER_NAME}®isterForm[email]=${ADMIN_USER_NAME}@localhost®isterForm[password]=${ADMIN_USER_PASS}&_csrf=${CSRF}"
- script:
name: "Login as admin1"
code: |
OUTPUT_PAGE_NAME=login.html
curl $GROWI_URL/login -c ${LOGIN_COOKIE} -o ${OUTPUT_PAGE_NAME}
CSRF=`grep data-csrftoken ${OUTPUT_PAGE_NAME} | awk -F'=' '{ print $2 }' | sed -e s/\"//g`
curl $GROWI_URL/login -b ${LOGIN_COOKIE} -X POST -d "loginForm[username]=${ADMIN_USER_NAME}&loginForm[password]=${ADMIN_USER_PASS}&_csrf=${CSRF}"
- script:
name: "Generate API token"
code: |
OUTPUT_PAGE_NAME=apiToken.html
curl $GROWI_URL/me/apiToken -b ${LOGIN_COOKIE} -o ${OUTPUT_PAGE_NAME}
CSRF=`grep data-csrftoken ${OUTPUT_PAGE_NAME} | awk -F'=' '{ print $2 }' | sed -e s/\"//g`
curl $GROWI_URL/me/apiToken -b ${LOGIN_COOKIE} -X POST -d "apiTokenForm[confirm]=1&_csrf=${CSRF}"
curl $GROWI_URL/me/apiToken -b ${LOGIN_COOKIE} -o ${OUTPUT_PAGE_NAME}
export APITOKEN=`grep -A 10 'Current API Token' ${OUTPUT_PAGE_NAME} | grep '<input' | awk -F'value=' '{ print $2 }' | awk -F'"' '{ print $2 }'`
- script:
name: "Export environment variables"
code: |
export CROWI_URL=$GROWI_URL
export CROWI_ACCESS_TOKEN=$APITOKEN
- script:
name: "View environment variables"
code: |
env
- script:
name: rspec
code: bundle exec rspec