forked from plfa/plfa.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtravis-build-cache.sh
executable file
·44 lines (39 loc) · 1.22 KB
/
travis-build-cache.sh
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
#!/bin/bash
# Dependencies:
# - curl <https://curl.haxx.se/>
# - yq <https://github.com/mikefarah/yq>
# Modify .travis.yml:
# - Remove 'script' and 'deploy' phases;
# - Add 'merge_mode';
# - Create JSON request.
#
body=$(cat .travis.yml \
| yq w - script "echo 'Done'"\
| yq d - before_deploy \
| yq d - deploy \
| yq p - config \
| yq w - message "Build cache" \
| yq w - branch dev \
| yq w - merge_mode replace \
| yq p - request -j)
# Send request to Travis.
#
resp=$(curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token $TRAVIS_TOKEN" \
-d "$body" \
https://api.travis-ci.org/repo/plfa%2Fplfa.github.io/requests)
# Output response.
#
echo "$resp" \
| yq d - request.configs \
| yq d - request.config \
| yq r - --prettyPrint
# Output configuration.
#
echo "$resp" \
| yq r - request.config \
| yq p - config \
| yq r - --prettyPrint