diff --git a/.circleci/config.yml b/.circleci/config.yml index 13d26caf46fd..c2858568fc17 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,31 +10,6 @@ aliases: - node_modules - website/node_modules key: v2-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }} - - - &website - command: | - if [[ $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then - # configure Docusaurus bot - git config --global user.email "docusaurus-bot@users.noreply.github.com" - 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: @@ -140,7 +115,9 @@ jobs: - restore-cache: *restore-cache - run: yarn --no-progress - save-cache: *save-cache - - run: *website + - run: + name: Test or Deploy Jest Website + command: ./.circleci/website.sh # Workflows enables us to run multiple jobs in parallel workflows: diff --git a/.circleci/website.sh b/.circleci/website.sh new file mode 100755 index 000000000000..2c3e5a3c7b75 --- /dev/null +++ b/.circleci/website.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -e + +git diff-tree --no-commit-id --name-only -r HEAD > files_changed.txt +if ! grep -E "(^docs\/.*)|(^website\/.*)" files_changed.txt; then + echo "Skipping deploy & test. No relevant website files have changed" +else + echo "Relevant website files have changed" + if [[ $CIRCLE_PROJECT_USERNAME == "facebook" && -z $CI_PULL_REQUEST && -z $CIRCLE_PR_USERNAME ]]; then + # configure Docusaurus bot + git config --global user.email "docusaurus-bot@users.noreply.github.com" + 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 + # 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 81687c6215de..a6c4c536b726 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - `[*]` Transpile object shorthand into Node 4 compatible syntax ([#6582](https://github.com/facebook/jest/pull/6582)) - `[*]` Update all legacy links to jestjs.io ([#6622](https://github.com/facebook/jest/pull/6622)) - `[docs]` Add docs for 23.1, 23.2, and 23.3 ([#6623](https://github.com/facebook/jest/pull/6623)) +- `[website]` Only test/deploy website if relevant files are changed ([#6626](https://github.com/facebook/jest/pull/6626)) ## 23.2.0