19 September 2021

Publishing Blot Posts From Github

I’m interested in coming up with a technique for publishing Blot posts from computers that are not my own. I previously had a tool which helped me here but it’s not working properly and I haven’t looked at it for a while. Also, I was uncomfortable running it on machines that I don’t have full control over, such as my work laptop.

Since I’m using Git for this Blot blog, I’m wondering if simply typing posts directly into Github would work. The workflow I’d like to try is:

  • Creating new files in Github and using the builtin web editor.
  • Committing the changes to the main branch once they’re ready.
  • Using Github Actions to automatically push the changes to Blot.im

Setting up the Github repository was relatively easy. Once I created it, I renamed the existing Blot origin to blot, and changed origin to the new Github repository:

git remote rename origin blot
git remote add origin git@github.com:lmika/random-development-blog.git
git branch -M main
git push -u origin main

Adding a workflow to publish to Blot when pushing to main took a bit longer, but after some trial and error (and many emails from Github about failed action runs), I eventually got a workflow which does this:

# Filename: .github/workflows/publish.yml
#

name: publish

on:
  push:
    branches:
      - main

jobs:
  publish-to-blot:
    name: Publish to Blot
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Setting up credentials
        env:
          BLOT_LOGIN: ${ { secrets.BlotLogin }}
        run: |
          git config credential.helper store
          echo "https://${BLOT_LOGIN}@blot.im/" >> $HOME/.git-credentials
      - name: Push to Blot.im
        run: |
          git remote add blot 'https://blot.im/clients/git/end/therandomdevelopmentblog.git'
          git push --force blot main:master

Note: There’s a bug in Blot which does not allow for two open curly braces, so that space between the { for the BLOT_LOGIN environment variable does not actually appear in the file.

Having the fetch-depth: 0 in the checkout action is important. By default, this action creates a shallow clone of the repo, but Blot needs to full clone or it won’t accept the push. I also had to include my Blot Git credentials some way. This was easy to do using Github repository secrets:

  1. Go to the Settings” tab in Github.

  2. Go to the Secrets” tab.

  3. Create a new secret with the name BlotLogin”

  4. Set the value of the secret to <username>:<password> where username and password are the ones generated by Blot. If the username is an email, which it is for me, then the @ sign will need to be encoded as %40 so that it looks like:

    user%40example.com:password

We’ll see if this works as a way of getting posts into Blot. I guess at the very least, it’s good to have an extra copy of this blog.


Techniques


Previous post
Weekly Project Update 11 It’s been a week since the alpha release of Feed Journal and so far things are going reasonably well. A handful of people have given it a shot,
Next post
Weekly Project Update 12 There are weeks when you’ve got a lot of exciting things to say about a project, like the addition of a brand new whizzbang feature. And there are