I wanted to be able to publish this site using Travis instead of AppVeyor, just to try.

I found this with Google: https://github.com/jkeylu/deploy-hexo-site-by-travis-ci/blob/master/_travis.yml

I’m not pushing to GitHub pages but to a FTP so I had to slightly modify the yml following this documentation from Travis site:

- "FTP_USER=user"
- "FTP_PASSWORD=password"
"curl --ftp-create-dirs -T uploadfilename -u $FTP_USER:$FTP_PASSWORD ftp://sitename.com/directory/myfile"

Unfortunately, there are multiple issues with this:

  • One, it only uploads one file, not a full folder
  • Two, if the upload fails, it does not break the build.

To upload a full folder, I found this on Stack Overflow:

find mydir -type f -exec curl -u xxx:psw --ftp-create-dirs -T {}{} \;

It is closer but I had to replace -exec parameter by piping to xargs because -exec does not return a -1 exit code in case of failure.

For escaping data to yaml, I used https://www.json2yaml.com/

In then end, the solution of using after_success is not cool, because in my case, that I consider build is publishing the site to the ftp. So if this step fails, I want the build to fail.

With after_success, the build is still green if this step fails. See https://docs.travis-ci.com/user/customizing-the-build/#Breaking-the-Build

I also tried that: https://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines
(did not worked)

So, in the end, I dropped Travis.