[Security]: Moving to a secure way of uploading assets (#2747)

* [Security] Moving to a secure way of uploading assets
italian
Agniva De Sarker 2019-02-03 19:27:35 +05:30 committed by Marco Bonelli
parent 1799a53d78
commit 1e28a0cbc0
3 changed files with 7 additions and 10 deletions

View File

@ -6,14 +6,11 @@ node_js:
cache: false
after_success:
- eval "$(ssh-agent -s)"
- openssl aes-256-cbc -K $encrypted_973441be79af_key -iv $encrypted_973441be79af_iv -in ./scripts/id_ed25519_tldr_asset_upload.enc -out id_ed25519 -d
- chmod 600 id_ed25519
- ssh-add id_ed25519
- bash scripts/build.sh
after_failure:
- cat test_result | python scripts/send_to_bot.py
env:
global:
# Used to upload the tldr archive to tldr-pages repo.
# Achieved via the upload_assets() function of scripts/build.sh
# This is an encrypted form of @agnivade's user token.
- secure: AJPra/q3bCFHzMOam1aFz4tzasYuU261Mk6lISh1VJatibHa7nBErsuA3VbR5qth9LblH5HFmNGl4bwmas/PTD1P3lPAHO19gdlMb1kpS9MhTojQP/0EPCsyMTgnWcmNMU2XMvYGHFT0JFn4vj/0TrM9CUMDoT9WhtnVJfgRrlY=

View File

@ -10,6 +10,7 @@ function initialize {
export TLDR_ARCHIVE="tldr.zip"
export SITE_HOME="$HOME/site"
export SITE_URL="github.com/tldr-pages/tldr-pages.github.io"
export SITE_REPO_SLUG="tldr-pages/tldr-pages.github.io"
git config --global user.email "travis@travis-ci.org"
git config --global user.name "Travis CI"
@ -29,13 +30,12 @@ function build_archive {
}
function upload_assets {
# ${GH_TOKEN} is defined as a secure variable inside .travis.yml
git clone --quiet --depth 1 https://${GH_TOKEN}@${SITE_URL} $SITE_HOME
git clone --quiet --depth 1 git@github.com:${SITE_REPO_SLUG}.git $SITE_HOME
mv -f $TLDR_ARCHIVE $SITE_HOME/assets/
cp -f $TLDRHOME/pages/index.json $SITE_HOME/assets/
cd $SITE_HOME
git add -A
git add -A
git commit -m "[TravisCI] uploaded assets after commits ${TRAVIS_COMMIT_RANGE}"
git push -q
}

Binary file not shown.