Semper Cogitare

Using GitHub Actions to add a new page to the GitHub repository using the iOS app #

So everything was set up to maintain my new blog. Every time I updated a file in GitHub a build pipeline would run and update my site. I was all ready to write a new blog post using the GitHub iOS app - and that's when I found that the Create new file option was not available. Crap!

Where there's a will, there's a way: GitHub Actions to the rescue. You'll recall that my 11ty_deploy workflow included a clause to ignore the file .generatedraft:

    paths-ignore:
- '.generatedraft'

This workflow (.github/workflows/generate_draft.yml) works exclusively when .generatedraft is updated. I should also note that I have a template draft blog post called yyyy-mm-dd-draft_post.md.

name: Generate_Draft

# Runs whenever the .generatedraft file is pushed to the repository
on:
push:
paths:
- '.generatedraft'

permissions:
contents: write # This is required to write back to the respository

jobs:
generatedraft:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Create draft file and push to repository
run: |
DRAFTNAME=`cat .generatedraft`
cp content/blog/yyyy-mm-dd-draft_post.md content/blog/$DRAFTNAME
git config user.name github-actions
git config user.email github-actions@github.com
git add content/blog/$DRAFTNAME
git commit -m "[skip ci]"
git push

So to create a new file I update the contents of .generatedraft to be 2023-01-01-happy_new_year.md (for example). When I commit the change the above workflow runs and a new file is created with that name. (Note that the [skip ci] keyword prevents the 11ty_deploy.yml workflow from running.)