Auto-publish pelican blog to S3 using CircleCI
While having blog powered by pelican is great (because it's fast), creating new post isn't really fun. There are more than one step to do it:
- writing the actual post
- upload to the server (in this case, S3)
If you're on new machine, it's even more painful:
- clone the repository
- install pelican's requirements
- setup S3 credential
- write the actual post
- upload to the server
CircleCi has given free tier for a while now. So I figured, since I'm using github for my blog content, I could use it's free continous integration & delivery service to publish my blog easily.
I found a blog post that gives instruction to do that, but apparently it doesn't work.
s3cmd
couldn't get the access key ID and secret access key I set. Since CircleCi has awscli
preinstalled,
it's better to use that one instead. Pelican doesn't support awscli yet,
so there's some steps need to be done to use that.
- update your
Makefile
to useawscli
instead - insert your AWS S3 access key ID, and secret key ID
- create circle.yml in your repository
Here's how the circle.yml should be:
:::yml
dependencies:
override:
- pip install -r requirements.txt
- echo -e "[default] \
access_key = $S3CFG_ACCESS_KEY \ secret_key = $S3CFG_SECRET_KEY \ " > /home/ubuntu/.s3cfg
test:
override:
- echo "test"
deployment:
aws:
branch: master
commands:
- make html
- make s3_upload
Now, everytime you push your commits to master, CircleCI will deploy them to S3. You should be able to see the deployment progress on you CircleCI dashboard.
You don't need to create special environment to install pelican etc, just git and text-editor. You could even use github's feature to create blog post directly inside your browser (I wrote this using that!).