Skip to content

Commit 9b840d0

Browse files
committed
Add travis scripts
This deploys the website as https://pmd-code.org/pmd7/
1 parent f03a2c3 commit 9b840d0

File tree

6 files changed

+120
-0
lines changed

6 files changed

+120
-0
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: ruby
2+
3+
script: bundle exec jekyll build
4+
after_success: source .travis/publish-website.sh
3.36 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCyMTaj86+7boC1AIfgMHzMwrvy59m8Cb70AcHIZvE9Y3x48e3f3ss+e0+ThTyh8QhMSeP9K7GXPoeTYCQLXSOCmNCgyvUow4ktvmbL006t1IwDjMORIwc+th+28QLBw7YNly6Jx005ForHGiNISCJoe8wgAhATLx9YeBtij8cOMauDS44f/4nRg4IA3frerfMOuePp+Q2nZQz9ohs1OE4XbQC5q1MhiIeL4GsM2NfvGrSNLkAdTOh1HGuypyHUn2+ZqxQD161DCjMJtfOnl9cRyXeAEeAPOIFon21RoPSPgLuS6hj2qXIgievJHRRAeihmkHAObtYi3nPmdOc4h4Vpz5mQO0VPCrVW8fQOoaSM05FeEA5G4tPCLcWYmUuj7KSoXL6Rnh0h2hmioQr9JdumN1+b4DJg7s+mRsY65bF55m8FjJ2DyYd2fmfM33vlKa45IW9SKpMa2vyyA+0HkRDcbv4cRDJL07W7rf8iKTvLCYRYYXPmBinJ2VyLDUmXLEpHJR2JWC9pKlBB6YRVCKYZwd3SblWQzcx+E6myGNexTekAtXIJ+rWAU42jbRbtR/S6C75BZGFe2Rm9pssPFXH0TfNPaCRRRlmlJ4ibFU7XUexzN0i6C/StktD/180U/eC0XXhdd3FEa8+vKD4OUA4OjcVHxH0uX3472xiQlP9yvw== travis.com/pmd/pmd.github.io accessing pmd-code.org

.travis/logger.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
COL_GREEN="\e[32m"
4+
COL_RED="\e[31m"
5+
COL_RESET="\e[0m"
6+
COL_YELLOW="\e[33;1m"
7+
8+
function log_error() {
9+
echo -e "${COL_RED}[ERROR ] $*${COL_RESET}"
10+
}
11+
12+
function log_info() {
13+
echo -e "${COL_YELLOW}[INFO ] $*${COL_RESET}"
14+
}
15+
16+
function log_success() {
17+
echo -e "${COL_GREEN}[SUCCESS] $*${COL_RESET}"
18+
}
19+
20+
function log_debug() {
21+
true
22+
#echo -e "[DEBUG ] $*"
23+
}

.travis/publish-website.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
source .travis/logger.sh
5+
6+
PMD_CODE_SSH_USER=pmd
7+
PMD_CODE_WEBSITE_PATH=/httpdocs/
8+
PMD_7_SUBPATH=pmd7/
9+
WEBSITE_ARCHIVE=pmd7-website.zip
10+
11+
#
12+
# The website is built already by jekyll into _site.
13+
# Then the folder _site is zipped into pmd7-website.zip.
14+
# This file is copied to ssh://[email protected]/httpdocs/
15+
# and then extracted into ssh://[email protected]/httpdocs/pmd7/
16+
#
17+
# The folder ssh://[email protected]/httpdocs/pmd7/ is available as
18+
# https://pmd-code.org/pmd7/
19+
#
20+
21+
function main() {
22+
if ! travis_isPush; then
23+
log_info "Not publishing site, since this is not a push!"
24+
exit 0
25+
fi
26+
27+
bash .travis/setup-secrets.sh
28+
29+
log_info "Zipping website..."
30+
cd _site
31+
zip -qr ../${WEBSITE_ARCHIVE} .
32+
cd ..
33+
ls -lh ${WEBSITE_ARCHIVE}
34+
35+
log_info "Uploading website..."
36+
scp ${WEBSITE_ARCHIVE} ${PMD_CODE_SSH_USER}@pmd-code.org:${PMD_CODE_WEBSITE_PATH}
37+
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_WEBSITE_PATH} && \
38+
rm -rf ${PMD_CODE_WEBSITE_PATH}/${PMD_7_SUBPATH} && \
39+
mkdir ${PMD_CODE_WEBSITE_PATH}/${PMD_7_SUBPATH} && \
40+
unzip -qo -d ${PMD_CODE_WEBSITE_PATH}/${PMD_7_SUBPATH} ${WEBSITE_ARCHIVE} && \
41+
rm ${WEBSITE_ARCHIVE}"
42+
43+
log_info "Updated website: https://pmd-code.org/pmd7/"
44+
}
45+
46+
function travis_isPush() {
47+
if [ "${TRAVIS_REPO_SLUG}" = "pmd/pmd.github.io" ] && [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${TRAVIS_SECURE_ENV_VARS}" = "true" ]; then
48+
return 0
49+
else
50+
return 1
51+
fi
52+
}
53+
54+
main

.travis/setup-secrets.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
source .travis/logger.sh
5+
6+
if [ "${TRAVIS_REPO_SLUG}" != "pmd/pmd.github.io" ] || [ "${TRAVIS_PULL_REQUEST}" != "false" ] || [ "${TRAVIS_SECURE_ENV_VARS}" != "true" ]; then
7+
echo "Not setting up secrets:"
8+
echo " TRAVIS_REPO_SLUG=${TRAVIS_REPO_SLUG}"
9+
echo " TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST}"
10+
echo " TRAVIS_SECURE_ENV_VARS=${TRAVIS_SECURE_ENV_VARS}"
11+
exit 0
12+
fi
13+
14+
echo "Setting up secrets..."
15+
16+
mkdir -p "$HOME/.ssh"
17+
chmod 700 "$HOME/.ssh"
18+
openssl aes-256-cbc -K $encrypted_f95f2a86c367_key -iv $encrypted_f95f2a86c367_iv -in .travis/id_travis-pmd-github-io_rsa.enc -out "$HOME/.ssh/id_rsa" -d
19+
chmod 600 "$HOME/.ssh/id_rsa"
20+
21+
22+
echo "Setting up .ssh/known_hosts..."
23+
#
24+
# run locally:
25+
# ssh-keyscan pmd-code.org | tee -a known_hosts
26+
#
27+
# verify fingerprints:
28+
# ssh-keygen -F pmd-code.org -l -f known_hosts
29+
# # Host pmd-code.org found: line 1
30+
# pmd-code.org ED25519 SHA256:nvkIAzZhYTxXqSU3DWvos83A0EocZ5dsxNkx1LoMZhg
31+
# # Host pmd-code.org found: line 2
32+
# pmd-code.org RSA SHA256:/uKehVNumCNvJL8C5CziwV9KkUUxHfggq0C4GTrUhwg
33+
# # Host pmd-code.org found: line 3
34+
# pmd-code.org ECDSA SHA256:6aD1r1XuIoc/zgBT3bt1S9L5ToyJzdQ9rrcMchnqiRA
35+
#
36+
# then add output of `ssh-keygen -F pmd-code.org -f known_hosts`
37+
#
38+
echo 'pmd-code.org ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVsIeF6xU0oPb/bMbxG1nU1NDyBpR/cBEPZcm/PuJwdI9B0ydPHA6FysqAnt32fNFznC2SWisnWyY3iNsP3pa8RQJVwmnnv9OboGFlW2/61o3iRyydcpPbgl+ADdt8iU9fmMI7dC04UqgHGBoqOwVNna9VylTjp5709cK2qHnwU450F6YcOEiOKeZfJvV4PmpJCz/JcsUVqft6StviR31jKnqbnkZdP8qNoTbds6WmGKyXkhHdLSZE7X1CFQH28tk8XFqditX93ezeCiThFL7EleDexV/3+2+cs5878sDMUMzHS5KShTjkxzhHaodhtIEdNesinq/hOPbxAGkQ0FbD' >> $HOME/.ssh/known_hosts

0 commit comments

Comments
 (0)