Jelajahi Sumber

Skip documentation update if CI build is invoked due to a pull request.

Yao Wei Tjong 姚伟忠 12 tahun lalu
induk
melakukan
0b60fc327e
2 mengubah file dengan 21 tambahan dan 7 penghapusan
  1. 2 2
      .travis.yml
  2. 19 5
      Rakefile

+ 2 - 2
.travis.yml

@@ -1,8 +1,8 @@
 language: cpp
 compiler: gcc
-before_install: sudo apt-get install -qq libx11-dev libxrandr-dev libasound2-dev libgl1-mesa-dev doxygen graphviz
+before_install: sudo apt-get install -qq libx11-dev libxrandr-dev libasound2-dev libgl1-mesa-dev doxygen graphviz rsync
 script: ./cmake_gcc.sh -DENABLE_64BIT=1 -DENABLE_LUAJIT=1 -DENABLE_LUAJIT_AMALG=1 -DENABLE_SAMPLES=1 -DENABLE_TOOLS=1 -DENABLE_EXTRAS=1 -DENABLE_DOCS_QUIET=1 && cd Build && make
 after_success: rake travis
 env:
   global:
-    secure: m2f+egBSG7UrMmLjldSQNF5WM+zq4DJEGvo+h9OgQ1jeIsm1fPGtcYHYLmJZdQ1bh8hRmFZ7TGXCHNAzdfRzlbfIW8WSUcpIsuFmbjPiV2zIckFSRGTyGnWApdQFDCZw1CyQ309fOSA6FrhT80yvcjX+C6+0aWO7LQTer/NFCFA=
+    secure: ST80PPq8cTIZ5WRgX4BJ7gKhHonNge9GdYH0PuTvCZot13Rk+oNkbzkkCT/KuQHmyUU65gE2HCyMYYqNDNyxy0Upi8jMUjgXdy7SN5zORVhyc/Ymfd6rt3sgVOT6YYlbegI3sFLVdaH4jdyyMqPQHW72StZ25NUQi0p682FAGD0=

+ 19 - 5
Rakefile

@@ -1,18 +1,32 @@
 require "rubygems"
 
-# Usage: NOT to be used manually
+# Usage: NOT intended to be used manually (if you insist then try: GIT_NAME=... GIT_EMAIL=... GH_TOKEN=... rake travis)
 desc 'Update site documentation to GitHub Pages'
 task :travis do
-  system 'git clone https://github.com/urho3d/urho3d.github.io.git doc-Build'
+  # Skip documentation update if it is a pull request
+  if ENV['TRAVIS_PULL_REQUEST'].to_i > 0
+    next
+  end
+  # Pull or clone
+  system 'cd doc-Build 2>/dev/null && git pull -q -r || git clone -q https://github.com/urho3d/urho3d.github.io.git doc-Build'
+  # Update credits from Readme.txt to about.md
   system "ruby -lne 'BEGIN { credits = false }; puts $_ if credits; credits = true if /bugfixes by:/; credits = false if /^$/' Readme.txt |ruby -i -le 'BEGIN { credits = STDIN.read }; puts ARGF.read.gsub(/(?<=bugfixes by\n).*?(?=##)/m, credits)' doc-Build/about.md"
-  system 'rm -rf doc-Build/documentation'
-  system 'cp -r Docs/html doc-Build/documentation'
+  # Sync generated doxygen pages (the trailing '/' is significant)
+  # \todo Do this without leaving file changes history in GIT
+  system 'rsync -a --delete Docs/html/ doc-Build/documentation'
+  # Supply GIT credentials for pushing to GitHub
   system "cd doc-Build && git config user.name '#{ENV['GIT_NAME']}'"
   system "cd doc-Build && git config user.email '#{ENV['GIT_EMAIL']}'"
   system 'cd doc-Build && git config credential.helper "store --file=.git/credentials"'
   File.open('doc-Build/.git/credentials', 'w') do |f|
     f.write("https://#{ENV['GH_TOKEN']}:@github.com")
   end
-  system "cd doc-Build && git add -A && git commit -q -a -m 'Travis CI automated site deploy at #{Time.now.utc}.' && git push -q"
+  system "cd doc-Build && git add -A && git commit -q -a -m 'Travis CI automated site documentation update at #{Time.now.utc}.' && git push -q"
+  # Debug start
+  system "echo GIT_NAME='#{ENV['GIT_NAME']}'"
+  system "echo GIT_EMAIL='#{ENV['GIT_EMAIL']}'"
+  system "GH_TOKEN='#{ENV['GH_TOKEN']}' echo GH_TOKEN=${GH_TOKEN:0:5}"
+  system 'cd doc-Build && git config --list'
+  # Debug end
   File.delete 'doc-Build/.git/credentials'
 end