16 Feb 2024

Instapaper's API via GitHub Actions

February's theme appears to be the Instapaper API. I am trying to auto run the sorting scripts without using some external virtual machine.

Picking up on my previous post, I have started running some of the organisation scripts on a cron, but not on a misc DigitalOcean virtual machine (which is my historical go-to), rather, using GitHub actions.

Sort It Out Yaml

# A basic example workflow to show how you can auto-run scripts to organise
# your Instapaper unread articles.
name: SortBookmarks

# Controls when the workflow will run

  - cron: "15 21 * * *"

  # Allows you to run this workflow manually from the Actions tab

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
  # This workflow contains a single job called "sort-it"
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3
      # Beyond standard Perl, we need one additional module
      - uses: perl-actions/install-with-cpanm@stable
          install: |

      # Import our required secrets to environment ready for the script to run
      - name: Run a multi-line script
          CLIENT_KEY: $
          CLIENT_SECRET: $
          X_AUTH_USERNAME: $
          X_AUTH_PASSWORD: $
        run: |
          echo "Running with $CLIENT_KEY key"
          PERL5LIB=lib perl examples/bookmarks-to-folder.pl

The pipeline is nice and straight forward and I think self explanatory with the comments in place. Source available here.

I initially thought I would configure the pipeline cron from the public repo, but decided this would just clutter the Action tab with useless runs that don’t mean anything to anyone else. My second approach was to have the repo duplicated in Github, one public and one private instance. The public one has Actions disabled, the private one has them enabled and the appropriate client auth secrets configured.

This seems to work well, with the caveat that I need to push updates to two git remotes which could become a chore, but seems fine for now.

Future Actions

I have not used a great deal of the GitHub Actions tool set, primarily using Azure DevOps with a little bit of GitLab for good measure. Having setup this Instapaper-sorting-script via a cron in a pipeline has got me wondering what else I’m running that is a good fit to be moved. Github provides 2000 minutes per month of free job time, and it’s available to private repos. Something to revisit later in the year I expect.

Back to posts