As the title says.
Pelican + There is a site operated by GitHub Pages.
I tried setting Travis CI to automatically generate HTML with the pelican command when I pushed an article to master and push it to the gh-pages branch to update the site.
Site: http://zaki-yama.github.io/salesforce-developers.info
I tried the type of GitHub Pages called ** Project Pages **. There are two types of GitHub Pages: ** User / Organization Pages ** and ** Project Pages **.
User/Organization Pages
--Repository name: [** GitHub account name **] .github.io
--Site URL: http: [** GitHub account name **] .github.io
--Branch name to push pre-build source code: optional
--Branch name to push HTML after build: master
Project Pages
--Repository name: Optional
--Site URL: http: [** GitHub account name **] .github.io / [** repository name **]
--Branch name to push pre-build source code: optional
--Branch name to push HTML after build: gh-pages
TL;DR
If you can read English, you can follow this article. http://blog.thomasemmerling.de/automatic-pelican-publishing-on-github-pages-via-travisci.html
travis command$ gem install travis
Reference: Creating an access token for command-line use --User Documentation
You need a token to push from Travis CI to the GitHub repository. Open Settings> Personal access tokens on GitHub and issue a new token with [Generate new token].
Copy the displayed character string.

Use the first installed travis command.
$ travis encrypt GH_TOKEN=[Copied token]
Shell completion not installed. Would you like to install it now? |y| y
Detected repository as zaki-yama/salesforce-developers.info, is this correct? |yes| yes
Please add the following to your .travis.yml file:
secure: "FLEqynRypa3B4S9qzcj0OTCwXrHUjEvsiXTI0r7qhZMzt11JUJUSzpVce/q5ZSENuBe9LR+c7MHl0pq9+1fka7bnYpbqWSybbIT5hLUVpIxB2ZvapogHmf9L/1n0vcODGhFwMUOfI1MuDN47wGCHS+qabNkIlzGGQPZYpri1ns1sp5rM7VFmVW6p3grAnhkaVWJIvW7GZORIPH11uBWtWsO2vhymrzM1J/PAgbJcSCjhtEZ79ntiG9DkAGqG27mVKPMNN8NDeIFGlbz2YyPgAqursSjZEPgmnzcQhzqyGz9D9Z5vAONki5vZ9CamEPfFa9llbQlwceM/7DJS+8FsBmiHH59i5rxW40iNK2otl6rSapXp1CLoWptXKVcyl9EjKcBUrRpWZ0Xzj94Ili80RbXiFJBW3B4qtrx7KCweUPURlY94a7n+P+pjbnx/jsdXFyvW4yR9R4+we82TxMPn49kq9Qf0cKnuEkVBOK1QyntdIDcW/L6heWqJAjWJMMGch4lSi0cN/8UGZxqq0b+OoHBp3FHWrnvOnLFB4mEgzp1/sa5jAFr6uq9mIS/TZ37XWrUX39YzAp6IL9Xq5Gmwof8nhKfnX7xm/yb3bglOt9HgrxArEKWoc/w/Gt4uxjGMQ2B9YjJsOdnxBHPpUgUXXxHj0FaD6K0pHLpJRQ+v78A="
Pro Tip: You can add it automatically by running with --add.
The string after secure: is the encrypted token, so copy it.
Create a .travis.yml file in the root of the repository and write as follows.
yaml:.travis.yml
language: python
branches:
only:
- master
install:
- pip install pelican
- pip install ghp-import
- pip install markdown
script:
- make publish
- make github
env:
global:
- secure: [token encrypted with travis encrypt command]
Edit the make github part of Pelican's Makefile.
In my case it was originally like this.
Makefile
PY?=python
PELICAN?=pelican
PELICANOPTS=
BASEDIR=$(CURDIR)
INPUTDIR=$(BASEDIR)/content
OUTPUTDIR=$(BASEDIR)/output
...(Omission)...
GITHUB_PAGES_BRANCH=master
...(Omission)...
github: publish
ghp-import -m "Generate Pelican site" -b $(GITHUB_PAGES_BRANCH) $(OUTPUTDIR)
git push origin $(GITHUB_PAGES_BRANCH)
.PHONY: html help clean regenerate serve serve-global devserver publish ssh_upload rsync_upload dropbox_upload ftp_upload s3_upload cf_upload github
Modify the last part of github: publish like this.
Makefile(Revised)
github: publish
ghp-import $(OUTPUTDIR)
@git push -fq https://${GH_TOKEN}@github.com/$(TRAVIS_REPO_SLUG).git gh-pages > /dev/null
ghp-import before modification is probably for User / Organization Pages,
This will push the HTML file generated by ghp-import to the master branch.
ghp-import becomes gh-pages if -b is omitted.masterCommit the modified Makefile with .travis.yml and push it to the master branch.
If the settings are correct, the Travis CI build will run, and the Pelican build and push to the gh-pages branch will be performed automatically.
I wanted to make the article before publication a separate branch, create a Pull Request to master, merge it, build it, and publish the article.
As soon as I made the PR, the build ran and I was impatient, but it was in the Travis CI Settings.

Reference: I tried using Travis CI: I wanted to put a badge on the repository on GitHub
Click on the build unknown badge in Travis CI's admin console, select Markdown and copy the text that appears.

Paste it into the README.md and push it to see the badge.

Recommended Posts