Skip to content

Commit 8c8c1fc

Browse files
committed
Update CircleCI job to trigger a Travis CI job for trpl-ja-pdf
1 parent fb31d86 commit 8c8c1fc

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

circle.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,5 @@ deployment:
6666
# are updated from 1.6.
6767
- rm -rf docs/1.9
6868
- ./tools/circleci/push-to-master.sh
69+
- ./tools/circleci/trigger-trpl-pdf-ja.sh
6970
# - ./tools/circleci/publish-to-gh-pages.sh

tools/circleci/trigger-trpl-pdf-ja.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
3+
# This script triggers a Travis CI build on trpl-ja-pdf to generates
4+
# PDF files of TRPL. It does so by sending a request to Travis's API
5+
# server.
6+
#
7+
# This script referes to the following mandatory and optional
8+
# environment variables:
9+
#
10+
# - TRPL_JA_PDF_TRAVIS_AUTH_TOKEN (Mandatory):
11+
# The auth token required by Travis CI web API. Since this
12+
# variable carries a sensitive data, it should not be defined in
13+
# circle.yml. Instead, it should be defined at Circle CI's web
14+
# console at:
15+
# https://circleci.com/gh/rust-lang-ja/the-rust-programming-language-ja/edit#env-vars
16+
#
17+
# To obtain a Travis auth token, follow the instructions on:
18+
# https://docs.travis-ci.com/user/triggering-builds/
19+
#
20+
# - TRPL_JA_PDF_GITHUB_REPO (Optional):
21+
# The GitHub repository name of trpl-ja-pdf, default to
22+
# `trpl-ja-pdf`. To override it, define this variable at
23+
# CircleCI's web console or in circle.yml.
24+
#
25+
# - TRPL_JA_PDF_GITHUB_ORG (Optional):
26+
# The GitHub organization or user name of trpl-ja-pdf, default to
27+
# `rust-lanu-ja`. To override it, define this variable at
28+
# CirildCI's web console or in circle.yml.
29+
30+
set -e
31+
32+
if [ -z "${TRPL_JA_PDF_TRAVIS_AUTH_TOKEN+x}" ]; then
33+
echo "ERROR: Environment variable TRPL_JA_PDF_TRAVIS_AUTH_TOKEN is undefined."
34+
echo " If you want to trigger a Travis CI build for trpl-ja-pdf,"
35+
echo " please read comments in this script to define the variable."
36+
exit 1
37+
fi
38+
39+
GITHUB_REPO=${TRPL_JA_PDF_GITHUB_REPO:-tarpl-ja-pdf}
40+
GITHUB_ORG=${TRPL_JA_PDF_GITHUB_ORG:-rust-lang-ja}
41+
42+
set -u
43+
44+
# Get the revision of current branch.
45+
REVISION=$(git rev-parse --short HEAD)
46+
47+
BUILD_PARAMS='{
48+
"request": {
49+
"branch": "master"
50+
"message": "automatic build triggered by trpl-ja commit ${REVISION}"
51+
}
52+
}'
53+
54+
echo "Triggering a build on Travis CI for ${GITHUB_ORG}/${GITHUB_REPO}."
55+
56+
set +e
57+
curl -s -X POST \
58+
-H "Content-Type: application/json" \
59+
-H "Accept: application/json" \
60+
-H "Travis-API-Version: 3" \
61+
-H "Authorization: token ${TRPL_JA_PDF_TRAVIS_AUTH_TOKEN}" \
62+
-d "$BUILD_PARAMS" \
63+
https://api.travis-ci.org/repo/${GITHUB_ORG}%2F${GITHUB_REPO}/requests
64+
RET=$?
65+
set -e
66+
67+
if [ $RET -eq 0 ]; then
68+
echo "Successfully triggered the Travis CI build."
69+
else
70+
echo "Failed to trigger the Travis CI build."
71+
exit 1
72+
fi

0 commit comments

Comments
 (0)