Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor into website.sh
  • Loading branch information
endiliey committed Jul 5, 2018
commit 56dfdd243405e8bac4bb83c995f3f346bc21c7f7
34 changes: 3 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,6 @@ aliases:
- node_modules
- website/node_modules
key: v2-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}

- &website
command: |
WEBSITE_CHANGED=$(git diff-tree --no-commit-id --name-only -r HEAD | grep -E -c "(^docs\/.*)|(^website\/.*)")
if [[ $WEBSITE_CHANGED == 0 ]]; then
echo "No relevant website files has changed"
exit 0;
fi
if [[ $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then
# configure Docusaurus bot
git config --global user.email "[email protected]"
git config --global user.name "Website Deployment Script"
echo "machine github.com login docusaurus-bot password $DOCUSAURUS_PUBLISH_TOKEN" > ~/.netrc
# install Docusaurus and generate file of English strings
yarn && cd website && yarn write-translations
# crowdin install
sudo apt-get update
sudo apt-get install default-jre rsync
wget https://artifacts.crowdin.com/repo/deb/crowdin.deb -O crowdin.deb
sudo dpkg -i crowdin.deb
sleep 5
# translations upload/download
yarn crowdin-upload
yarn crowdin-download
# build and publish website
GIT_USER=docusaurus-bot USE_SSH=false yarn publish-gh-pages
else
echo "Skipping deploy. Test website build"
cd website && yarn && yarn build
fi

- &filter-ignore-gh-pages
branches:
Expand Down Expand Up @@ -145,7 +115,9 @@ jobs:
- restore-cache: *restore-cache
- run: yarn --no-progress
- save-cache: *save-cache
- run: *website
- run:
command: |
.circleci/website.sh

# Workflows enables us to run multiple jobs in parallel
workflows:
Expand Down
30 changes: 30 additions & 0 deletions .circleci/website.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have set -e or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true. I forget 😢


WEBSITE_CHANGED=$(git diff-tree --no-commit-id --name-only -r HEAD | grep -E -c "(^docs\/.*)|(^website\/.*)")
if [[ $WEBSITE_CHANGED == 0 ]]; then
echo "No relevant website files has changed"
exit 0;
else
if [[ $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then
# configure Docusaurus bot
git config --global user.email "[email protected]"
git config --global user.name "Website Deployment Script"
echo "machine github.com login docusaurus-bot password $DOCUSAURUS_PUBLISH_TOKEN" > ~/.netrc
# install Docusaurus and generate file of English strings
yarn && cd website && yarn write-translations
# crowdin install
sudo apt-get update
sudo apt-get install default-jre rsync
wget https://artifacts.crowdin.com/repo/deb/crowdin.deb -O crowdin.deb
sudo dpkg -i crowdin.deb
sleep 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this sleep still needed?

Copy link
Contributor Author

@endiliey endiliey Jul 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh i don't think it is needed but I'm just following the previous script. Want to remove ?

Docusaurus use it though
https://github.com/facebook/Docusaurus/blob/3566483aa5fbe0b9cd6988aa14b255f4092ca4c7/.circleci/config.yml#L83

i didn't use it on my test site. Still works flawlessly 😂
https://github.com/endiliey/endiliey.github.io/blob/4c6abe0786e2be11cda2ae7c8d847e957d6ba89d/.travis.yml#L37-L41

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kill it

# translations upload/download
yarn crowdin-upload
yarn crowdin-download
# build and publish website
GIT_USER=docusaurus-bot USE_SSH=false yarn publish-gh-pages
else
echo "Skipping deploy. Test website build"
cd website && yarn && yarn build
fi
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing newline?