-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.drone.yml
259 lines (226 loc) · 7.07 KB
/
.drone.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
---
kind: pipeline
name: Default
trigger:
event:
include:
- push
steps:
- name: Install packages
image: composer
volumes:
- name: tools
path: /root/tools
commands:
- composer install --no-interaction
- mkdir -p /root/tools/phpcbf /root/tools/php-cs-fixer
- composer global require "squizlabs/php_codesniffer" --working-dir=/root/tools/phpcbf
- composer global require "friendsofphp/php-cs-fixer" --working-dir=/root/tools/php-cs-fixer
- name: Wait for mysql
image: mysql:5.7
commands:
- while ! mysqladmin ping -h mysql -u root -proot --silent; do sleep 1; done
depends_on:
- mysql
- name: firefly
image: fireflyiii/core
detach: true
environment:
APP_KEY: EUKY9laCopF9bkGDF9xvZyClzUAob7Yc
DB_HOST: mysql
DB_PORT: 3306
DB_CONNECTION: mysql
DB_DATABASE: firefly
DB_USERNAME: root
DB_PASSWORD: root
APP_ENV: testing
commands:
- cd /var/www/html/
# Remove "exec apache2-foreground" from the entry point script
- head -n -1 /usr/local/bin/entrypoint.sh > tmp.txt && mv tmp.txt /usr/local/bin/entrypoint.sh
- chmod +x /usr/local/bin/entrypoint.sh
- bash /usr/local/bin/entrypoint.sh
- php artisan firefly-iii:create-first-user [email protected]
- apache2-foreground
depends_on:
- Wait for mysql
- name: Wait for firefly
image: curlimages/curl
commands:
- while ! curl firefly:8080 ; do sleep 1 ; done
depends_on:
- firefly
- name: Add oauth client
image: mysql:5.7
commands:
- mysql -h mysql -u root -proot -e "INSERT INTO firefly.user_groups (id, created_at, updated_at, deleted_at, title) VALUES (null, '2022-01-01 00:00:00', '2022-01-01 00:00:00', NULL, '[email protected]');"
# Create new oauth client with a known id
- mysql -h mysql -u root -proot -e "INSERT INTO firefly.oauth_clients (id, user_id, name, secret, redirect, personal_access_client, password_client, revoked, created_at, updated_at, provider) VALUES (3, 1, 'Firefly III Password Access Client', '2C1EMlc8wiMpcheWOGi0829puwgFutt6TjDsptM2', 'http://localhost', '0', '1', '0', '2022-01-01 00:00:00', '2022-01-01 00:00:00', 'users');"
# Create asset account for PayPal
- mysql -h mysql -u root -proot -e "INSERT INTO firefly.accounts (id, created_at, updated_at, deleted_at, user_id, user_group_id, account_type_id, name, virtual_balance, iban, active, encrypted) VALUES ('1', '2022-01-01 00:00:00', '2022-01-01 00:00:00', NULL, '1', NULL, '3', 'Paypal', NULL, NULL, '1', '0');"
# Set password equal to H0plcPOsi5LDmBKxPTBUdubj
- mysql -h mysql -u root -proot -e "UPDATE firefly.users SET password = '\$2y\$10\$Y10M8.t2HhRk0JY5fqfJc.fS9GORgDgvywcwd35jiu0/EJnSFkvui', user_group_id = 1;"
depends_on:
- Wait for firefly
- name: Create Personal Access Token
image: alpine:3.18
commands:
- apk --no-cache add curl jq
- |
curl -fsSL --request POST 'http://firefly:8080/oauth/token' \\
--header 'Accept: application/json' \\
--form 'grant_type="password"' \\
--form 'client_id="3"' \\
--form 'client_secret="2C1EMlc8wiMpcheWOGi0829puwgFutt6TjDsptM2"' \\
--form 'username="[email protected]"' \\
--form 'password="H0plcPOsi5LDmBKxPTBUdubj"' | jq '.access_token' > token.txt
- echo -e "FIREFLY_TOKEN=$(cat token.txt)" > .env
depends_on:
- Add oauth client
- name: Run tests
image: php:8.1
environment:
FIREFLY_URI: 'firefly:8080'
FIREFLY_PAYPAL_ACCOUNT_ID: '1'
commands:
- . ./.env
- mkdir -p /data
- touch /data/database.sqlite
- vendor/bin/pest
depends_on:
- Create Personal Access Token
- Install packages
- name: Run linter
image: php:8.2
volumes:
- name: tools
path: /root/tools
commands:
- /root/tools/phpcbf/vendor/bin/phpcbf > /dev/null || true
- /root/tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config .php-cs-fixer.dist.php
depends_on:
- Install packages
- name: Commit changes by linter
image: alpine/git
commands:
- git add .
- git diff-index --quiet HEAD || git commit -m "[skip ci] :art:\ Run linters"
- git pull origin $DRONE_TARGET_BRANCH --no-rebase
- git push --set-upstream origin $DRONE_TARGET_BRANCH
depends_on:
- Run linter
volumes:
- name: tools
temp: {}
services:
- name: mysql
image: mysql:5.7
environment:
MYSQL_DATABASE: firefly
MYSQL_ROOT_PASSWORD: root
---
kind: pipeline
name: Build Docker container (latest)
depends_on:
- Default
trigger:
event:
include:
- push
branch:
- master
steps:
- name: Build Docker container
image: docker
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- docker build -t robvankeilegom/firefly-iii-paypal-importer:latest .
- name: Publish Docker container
image: docker
environment:
DOCKER_USER:
from_secret: docker_username
DOCKER_PW:
from_secret: docker_password
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- echo $DOCKER_PW | docker login --username $DOCKER_USER --password-stdin
- docker push robvankeilegom/firefly-iii-paypal-importer:latest
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
---
kind: pipeline
name: Build Docker container (develop)
depends_on:
- Default
trigger:
event:
include:
- push
branch:
- develop
steps:
- name: Build Docker container
image: docker
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- docker build -t robvankeilegom/firefly-iii-paypal-importer:develop .
- name: Publish Docker container
image: docker
environment:
DOCKER_USER:
from_secret: docker_username
DOCKER_PW:
from_secret: docker_password
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- echo $DOCKER_PW | docker login --username $DOCKER_USER --password-stdin
- docker push robvankeilegom/firefly-iii-paypal-importer:develop
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
---
kind: pipeline
name: Build Docker for specific tag
depends_on:
- Default
trigger:
event:
include:
- tag
steps:
- name: Build Docker container
image: docker
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- docker build -t robvankeilegom/firefly-iii-paypal-importer:$DRONE_TAG .
- name: Publish Docker container
image: docker
environment:
DOCKER_USER:
from_secret: docker_username
DOCKER_PW:
from_secret: docker_password
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- echo $DOCKER_PW | docker login --username $DOCKER_USER --password-stdin
- docker push robvankeilegom/firefly-iii-paypal-importer:$DRONE_TAG
volumes:
- name: dockersock
host:
path: /var/run/docker.sock