mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
Add webpack building, ESLint on PRs, and tag building to Travis (#911)
* Make Travis run ESLint before deploying * Fix Travis never building docs for tags * Update deploy.sh to also build the webpack * Update deploy.sh
This commit is contained in:
committed by
Schuyler Cebulskie
parent
2440a4a2c8
commit
176859e7da
@@ -5,7 +5,9 @@ cache:
|
|||||||
directories:
|
directories:
|
||||||
- node_modules
|
- node_modules
|
||||||
install: npm install
|
install: npm install
|
||||||
script: bash ./docs/deploy/deploy.sh
|
script:
|
||||||
|
- npm run test
|
||||||
|
- bash ./docs/deploy/deploy.sh
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- ENCRYPTION_LABEL: "af862fa96d3e"
|
- ENCRYPTION_LABEL: "af862fa96d3e"
|
||||||
|
|||||||
@@ -4,7 +4,11 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
function build {
|
function build {
|
||||||
|
# Build docs
|
||||||
node docs/generator
|
node docs/generator
|
||||||
|
|
||||||
|
# Build the webpack
|
||||||
|
VERSIONED=false npm run web-dist
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ignore Travis checking PRs
|
# Ignore Travis checking PRs
|
||||||
@@ -15,7 +19,9 @@ if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Ignore travis checking other branches irrelevant to users
|
# Ignore travis checking other branches irrelevant to users
|
||||||
if [ "$TRAVIS_BRANCH" != "master" -a "$TRAVIS_BRANCH" != "indev" ]; then
|
# Apparently Travis considers tag builds as separate branches so we need to
|
||||||
|
# check for that separately
|
||||||
|
if [ "$TRAVIS_BRANCH" != "master" -a "$TRAVIS_BRANCH" != "indev" -a "$TRAVIS_BRANCH" != "$TRAVIS_TAG" ]; then
|
||||||
echo "deploy.sh: Ignoring push to another branch than master/indev"
|
echo "deploy.sh: Ignoring push to another branch than master/indev"
|
||||||
build
|
build
|
||||||
exit 0
|
exit 0
|
||||||
@@ -29,19 +35,27 @@ if [ -n "$TRAVIS_TAG" ]; then
|
|||||||
SOURCE=$TRAVIS_TAG
|
SOURCE=$TRAVIS_TAG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Initialise some useful variables
|
||||||
REPO=`git config remote.origin.url`
|
REPO=`git config remote.origin.url`
|
||||||
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
|
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
|
||||||
SHA=`git rev-parse --verify HEAD`
|
SHA=`git rev-parse --verify HEAD`
|
||||||
|
|
||||||
TARGET_BRANCH="docs"
|
# Decrypt and add the ssh key
|
||||||
|
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
|
||||||
|
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
|
||||||
|
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
|
||||||
|
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
|
||||||
|
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in docs/deploy/deploy_key.enc -out deploy_key -d
|
||||||
|
chmod 600 deploy_key
|
||||||
|
eval `ssh-agent -s`
|
||||||
|
ssh-add deploy_key
|
||||||
|
|
||||||
|
# Build everything
|
||||||
|
build
|
||||||
|
|
||||||
# Checkout the repo in the target branch so we can build docs and push to it
|
# Checkout the repo in the target branch so we can build docs and push to it
|
||||||
|
TARGET_BRANCH="docs"
|
||||||
git clone $REPO out -b $TARGET_BRANCH
|
git clone $REPO out -b $TARGET_BRANCH
|
||||||
cd out
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
# Build the docs
|
|
||||||
build
|
|
||||||
|
|
||||||
# Move the generated JSON file to the newly-checked-out repo, to be committed
|
# Move the generated JSON file to the newly-checked-out repo, to be committed
|
||||||
# and pushed
|
# and pushed
|
||||||
@@ -49,20 +63,28 @@ mv docs/docs.json out/$SOURCE.json
|
|||||||
|
|
||||||
# Commit and push
|
# Commit and push
|
||||||
cd out
|
cd out
|
||||||
|
git add .
|
||||||
git config user.name "Travis CI"
|
git config user.name "Travis CI"
|
||||||
git config user.email "$COMMIT_AUTHOR_EMAIL"
|
git config user.email "$COMMIT_AUTHOR_EMAIL"
|
||||||
|
|
||||||
git add .
|
|
||||||
git commit -m "Docs build: ${SHA}"
|
git commit -m "Docs build: ${SHA}"
|
||||||
|
git push $SSH_REPO $TARGET_BRANCH
|
||||||
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
|
|
||||||
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
|
# Clean up...
|
||||||
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
|
cd ..
|
||||||
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
|
rm -rf out
|
||||||
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in ../docs/deploy/deploy_key.enc -out deploy_key -d
|
|
||||||
chmod 600 deploy_key
|
# ...then do the same once more for the webpack
|
||||||
eval `ssh-agent -s`
|
TARGET_BRANCH="webpack"
|
||||||
ssh-add deploy_key
|
git clone $REPO out -b $TARGET_BRANCH
|
||||||
|
|
||||||
# Now that we're all set up, we can push.
|
# Move the generated webpack over
|
||||||
|
mv webpack/discord.js out/discord.$SOURCE.js
|
||||||
|
mv webpack/discord.min.js out/discord.$SOURCE.min.js
|
||||||
|
|
||||||
|
# Commit and push
|
||||||
|
cd out
|
||||||
|
git add .
|
||||||
|
git config user.name "Travis CI"
|
||||||
|
git config user.email "$COMMIT_AUTHOR_EMAIL"
|
||||||
|
git commit -m "Webpack build: ${SHA}"
|
||||||
git push $SSH_REPO $TARGET_BRANCH
|
git push $SSH_REPO $TARGET_BRANCH
|
||||||
|
|||||||
Reference in New Issue
Block a user