DEV Community

Cover image for London Perl Mongers on GitHub Pages
Dave Cross
Dave Cross

Posted on • Originally published at perlhacks.com on

London Perl Mongers on GitHub Pages

The London Perl Mongers have had a website for a very long time. Since some time in 1998, I think. At first, I hosted a static site for us. Later on, we bought our own server and hosted it at a friendly company around Silicon Roundabout. But for most of the lifetime of the organisation, it’s been hosted on a server donated to us by Exonetric (for which we are extremely grateful).

But all good things come to an end. And last week, we got an email saying the Exonetric was closing down and we would need to find alternative hosting by the end of February.

The code for the site is on GitHub, so I had a quick look at it to see if there was anything easy we could do.

I was slightly surprised to find it was a PSGI application. Albeit a really simple PSGI application that basically served content from a /root directory, having passed it through some light Template Toolkit processing first. Converting this to a simple static site that could be hosted on GitHub Pages was going to be simple.

Really, all it needed was a ttree configuration file that reads all of the files from /root, processes them and writes the output to /docs. The configuration file I created looked like this:

src = root
dest = docs

copy = \.(gif|png|jpg|pdf|css|js)$
copy = ^CNAME$

recurse

verbose
Enter fullscreen mode Exit fullscreen mode

To be honest, most of the static web site work I do these days uses a static site builder that’s rather more complex than that, so it was really refreshing to remind myself that you can do useful things with tools as simple as ttree.

The next step was to add a GitHub Actions workflow that publishes the site to the GitHub Pages server each time something changes. That’s all pretty standard stuff too:

name: Generate web page

on:
  push:
    branches: 'master'
  workflow_dispatch:

jobs:
  build:
    if: github.repository_owner == 'LondonPM'
    runs-on: ubuntu-latest

    steps:
      - name: Install TT
        run: |
          sudo apt-get update
          sudo apt-get -y install libtemplate-perl

      - name: Checkout
        uses: actions/checkout@v4

      - name: Create pages
        run: ttree -f ttreerc 2>&1 > ttree.log

      - name: Archive ttree logs
        uses: actions/upload-artifact@v4
        with:
          name: ttree.log
          path: ./ttree.log
          retention-days: 3

      - name: Update pages artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: docs/

  deploy:
    needs: build
      if: github.repository_owner == 'LondonPM'
      permissions:
        pages: write
        id-token: write
      environment:
        name: github-pages
        url: ${{ steps.deployment.outputs.page_url }}
      runs-on: ubuntu-latest
      steps:
        - name: Deploy to GitHub Pages
          id: deployment
          uses: actions/deploy-pages@v4
Enter fullscreen mode Exit fullscreen mode

The only slightly complex lines here are the two lines that say if: github.repository_owner == 'LondonPM'. We’re hoping that other people will fork this repo in order to work on the site, but it’s only the main fork that should attempt to publish the current version on the GitHub Pages servers.

There was a bit of fiddling with DNS. Temporarily, we used the domain londonperl.com as a test deployment (because I’m the kind of person who just happens to have potentially useful domains lying around, unused!) but enough of us are slightly obsessed about using the correct TLD so we’ve settled on londonperl.org[*]. We’ve asked the nice people at the Perl NOC to redirect our old domain to the new one.

And it’s all working (well, with the exception of the redirection of the old domain). Thanks to Sue, Lee and Leo for the work they’ve done in the last few days to get it all working. And a big thanks to Mark and Exonetric for hosting the site for us for the last couple of decades.

These changes are already having the desired effect. People are submitting pull requests to update the website. Our website is probably more up-to-date than it has been for far too long. It’s even responsive now.

I realise there has been very little Perl in this post. But I thought it might be useful for other Perl Mongers groups who are looking for a simple (and free!) space to host their websites. Please let me know if you have any questions about the process.

[*] We wanted to use Cloudflare to manage the domain but their free service only supports top-level domains and london.pm.org (our original domain) is a subdomain – and none of us wanted to pay for the enterprise version.

The post London Perl Mongers on GitHub Pages appeared first on Perl Hacks.

Top comments (0)