diff --git a/.travis.yml b/.travis.yml
index dec791776e17550a0ce5e3f55a7d2026c00c49d2..45360b1810c773692bb5df6944ee657826c444cb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -70,7 +70,7 @@ before_install:
  # NB: these commands MUST be in .travis.yml, otherwise the secret key can be
  # leaked! See https://github.com/travis-ci/travis.rb/issues/423.
  # umask to get the permissions to be 400.
- - if [ "x$TRAVIS_PULL_REQUEST" = "xfalse" -a "x$TRAVIS_BRANCH" = "xmaster" -a "x$DEPLOY_DOCS" = "xYES"  ]; then (umask 377 && openssl aes-256-cbc -K $encrypted_edaf6551664d_key -iv $encrypted_edaf6551664d_iv -in id_rsa_cabal_website.aes256.enc -out ~/.ssh/id_rsa -d); fi
+ - if [ "x$TRAVIS_REPO_SLUG" = "xhaskell/cabal" -a "x$TRAVIS_PULL_REQUEST" = "xfalse" -a "x$TRAVIS_BRANCH" = "xmaster" -a "x$DEPLOY_DOCS" = "xYES"  ]; then (umask 377 && openssl aes-256-cbc -K $encrypted_edaf6551664d_key -iv $encrypted_edaf6551664d_iv -in id_rsa_cabal_website.aes256.enc -out ~/.ssh/id_rsa -d); fi
 
 install:
  # We intentionally do not install anything before trying to build Cabal because
diff --git a/travis-deploy.sh b/travis-deploy.sh
index e18d96f97115e3dd02e6d3bdb7c0eb32e3b0e37b..7bdb7587f3d601980824ae1fb21de04849f6d014 100755
--- a/travis-deploy.sh
+++ b/travis-deploy.sh
@@ -6,15 +6,22 @@ deploy() {
     git config --global user.name "Travis CI User"
     git clone https://github.com/haskell/cabal-website.git cabal-website
     (cd cabal-website && git checkout --track -b gh-pages origin/gh-pages)
+    rm -rf cabal-website/doc
     mkdir -p cabal-website/doc/html
-    mv dist-newstyle/build/Cabal-1.25.0.0/doc/html/Cabal cabal-website/doc/html/Cabal
+    mv dist-newstyle/build/Cabal-1.25.0.0/doc/html/Cabal \
+       cabal-website/doc/html/Cabal
     (cd cabal-website && git add --all .)
-    (cd cabal-website && git commit --amend --reset-author -m "Deploy to GitHub ($(date)).")
-    (cd cabal-website && git push --force git@github.com:haskell/cabal-website.git gh-pages:gh-pages)
+    (cd cabal-website && \
+            git commit --amend --reset-author -m "Deploy to GitHub ($(date)).")
+    (cd cabal-website && \
+            git push --force git@github.com:haskell/cabal-website.git \
+                gh-pages:gh-pages)
 }
 
-if [ "x$TRAVIS_PULL_REQUEST" = "xfalse" -a "x$TRAVIS_BRANCH" = "xmaster" \
-                             -a "x$DEPLOY_DOCS" = "xYES" ]
+if [ "x$TRAVIS_REPO_SLUG" = "xhaskell/cabal" \
+                          -a "x$TRAVIS_PULL_REQUEST" = "xfalse" \
+                          -a "x$TRAVIS_BRANCH" = "xmaster" \
+                          -a "x$DEPLOY_DOCS" = "xYES" ]
 then
     deploy
 fi