DrolleryMedieval drollery of a knight on a horse
flowery border with man falling
flowery border with man falling

This is my Github workflow. This file is a literate file that uses org-tangle to “compile” the needed yaml for Github.

Current Workflow

This action builds the sylvan project and then pushes the build to CF pages via Wrangler. I’m doing it this way instead of using the CI built into CF Pages because I merge my org content into my Astrojs project.

Triggers

Step one, we declare the workflow, and when it can be triggered.

In this case, the workflow triggers on changes to the master branch:

name: GitHub Actions Production Deployment

on:
  push:
    branches:
      - master

We also are going to trigger when the upstream NextJS project, Sylvan, is updated, so we added a repository_dispatch trigger:

repository_dispatch:
  types:
    - sylvan-update

And lastly, let’s add the workflow_dispatch trigger so we can kick off the build manually:

workflow_dispatch:

Jobs

Next we declare the jobs, in this case there is only one, Deploy-Production, it run’s on the latest version of Ubuntu, and it has a number of steps…

jobs:
  Deploy-Production:
    runs-on: ubuntu-latest
    steps:

Steps

Checkout and Cleanup

We actually have to checkout two different repos. First let’s checkout the Sylvan repo to the root of our action:

- name: Checkout Sylvan
  uses: actions/checkout@v4
  with:
    repository: ispringle/sylvan

Now we checkout the org repo (which is the repo this action runs it, but you cannot view it since it’s a private repo), and we check it out to the org/ directory within the Sylvan project:

- name: Checkout Org content
  uses: actions/checkout@v2
  with:
    path: content/

Now we’re going to remove any files that I have marked as private. I don’t think this is needed any longer, but it doesn’t hurt…

- name: "Remove files marked :PRIVATE: t"
  run: 'find ./content -type f -exec grep -q "^:PRIVATE: t\$" {} \; -delete'

Setting the Timezone

I don’t think this actually is doing anything, but I’m setting it just in case…

- name: Set Timezone
  uses: szenius/[email protected]
  with:
    timezoneLinux: "Americas/Chicago"

Build and Deploy!

Now we setup and build the project:

- name: Set Node.js
  uses: actions/setup-node@v3
  with:
    node-version: 18
- name: Instal deps
  uses: borales/actions-yarn@v4
  with:
    cmd: install
- name: Build
  uses: borales/actions-yarn@v4
  with:
    cmd: build

Finally we push to CF Pages with the Wrangle action:

- name: Publish
  uses: cloudflare/wrangler-[email protected]
  with:
    apiToken: ${{ secrets.CF_API_TOKEN }}
    accountId: ${{ secrets.CF_ACCOUNT_ID }}
    command: pages publish --project-name=org dist

Old Workflows

These are workflows I’ve used in the past but currently am not using.

Build with org-publish and deploy to Neocities

Triggers

Step one, we declare the workflow, and when it can be triggered.

In this case, the workflow triggers on changes to the master branch:

name: GitHub Actions Production Deployment

on:
  push:
    branches:
      - master

And let’s add the workflow_dispatch trigger so we can kick off the build manually:

workflow_dispatch:

Jobs

Next we declare the jobs, in this case there is only one, Deploy-Production, it run’s on the latest version of Ubuntu, and it has a number of steps…

jobs:
  Deploy-Production:
    runs-on: ubuntu-latest
    steps:

Steps

Checkout and Cleanup

We can checkout this repo:

- name: Checkout org
  uses: actions/checkout@v2

Now we’re going to remove any files that I have marked as private:

- name: "Remove files marked :PRIVATE: t"
  run: 'find ./ -type f -exec grep -q "^:PRIVATE: t\$" {} \; -delete'

Lastly, we need to install figlet to make the banner for the site’s header.

- name: "Instal dependencies"
  run: 'sudo apt-get install -y figlet'

Setting the Timezone

I don’t think this actually is doing anything, but I’m setting it just in case…

- name: Set Timezone
  uses: szenius/[email protected]
  with:
    timezoneLinux: "Americas/Chicago"

Build and Deploy!

Now we install the Vercel CLI, pull in the Vercel project, build it, and push it. This is all right from the Vercel documents with no changes:

- name: Install emacs
  uses: purcell/setup-emacs@master
  with:
    version: 28.2
- name: Run org-publish
  working-directory: ./build/
  run: sh build.sh
- name: Deploy to neocities
  uses: bcomnes/deploy-to-neocities@v1
  with:
    api_token: ${{ secrets.NEOCITIES_API_TOKEN }}
    dist_dir: build/_html/

Build with org-publish and deploy to Cloudflare Pages via Wrangler

This action builds the sylvan project and then pushes the build to CF pages via Wrangler. I’m doing it this way instead of using the CI built into CF Pages because I merge my org content into my Astrojs project.

Triggers

Step one, we declare the workflow, and when it can be triggered.

In this case, the workflow triggers on changes to the master branch:

name: GitHub Actions Production Deployment

on:
  push:
    branches:
      - master

We also are going to trigger when the upstream NextJS project, Sylvan, is updated, so we added a repository_dispatch trigger:

repository_dispatch:
  types:
    - sylvan-update

And lastly, let’s add the workflow_dispatch trigger so we can kick off the build manually:

workflow_dispatch:

Jobs

Next we declare the jobs, in this case there is only one, Deploy-Production, it run’s on the latest version of Ubuntu, and it has a number of steps…

jobs:
  Deploy-Production:
    runs-on: ubuntu-latest
    steps:

Steps

Checkout and Cleanup

We checkout the org repo (which is the repo this action runs it, but you cannot view it since it’s a private repo):

- name: Checkout Org content
  uses: actions/checkout@v2

Now we’re going to remove any files that I have marked as private. I do this because I’ve not figured out how to get org to read filetags:

- name: "Remove files marked :PRIVATE: t"
  run: 'find ./ -type f -exec grep -q "^:PRIVATE: t\$" {} \; -delete'

Then we remove drafts.

- name: "Remove files marked :DRAFT: t"
  run: 'find ./ -type f -exec grep -q "^:DRAFT: t\$" {} \; -delete'

Setting the Timezone

We do this because org-mode timestamps do not include the timezone and so they are liable to get created wrong. Not sure if it’s actually needed or not, but it’s here nonetheless

- name: Set Timezone
  uses: szenius/[email protected]
  with:
    timezoneLinux: "Americas/Chicago"

Build and Deploy!

Now we setup and build the project:

- name: Setup Emacs
  uses: purcell/setup-emacs@master
  with:
    version: 29.1
- name: Install Figlet
  run: sudo apt-get install -y figlet
- name: Build
  run: cd ./build/ && sh ./build.sh

Finally we push to CF Pages with the Wrangle action:

- name: Publish
  uses: cloudflare/wrangler-[email protected]
  with:
    apiToken: ${{ secrets.CF_API_TOKEN }}
    accountId: ${{ secrets.CF_ACCOUNT_ID }}
    command: pages deploy --project-name=org build/_html

Xrefs