Laravel Jigsaw deployed with GitHub Actions and Pages

VE
Vittorio Emmermann 1 month ago Follow on Twitter

While writing the docs for Laravel Architect I decided to use GitHub Pages instead of netlify. I did this since I had problems with the configuration of the PHP 7.3 build image at netlify. Here my snippets and hints for you.

Automate it

I'm not a big fan of manual deploys. Also not for small or not frequently used pages. One argument is that, unrelated to the update frequency, you'll have multiple different ways of deploying something if you're maintaining more than one project. So the easiest way to unify this deployment thing is to build a small CI for it. And if you want to update the page more often, you'll need it so or so because you want to save time with it. And there are more arguments also I don't want to mention here all in detail.

I decided to use GitHub actions for it because it's seamlessly integrated into GitHub, where I host all our code. I just created this small action:

name: Deploy docs
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  # This workflow contains a single job called "build"
  build:
    # 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
    steps:
    # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
    - uses: actions/checkout@v2

    - name: Setup Node.js environment
      uses: actions/setup-node@v1.4.2

    - name: setup-php
      uses: khs1994-docker/actions-setup-php@0.0.1

    - name: Composer and npm
      run: composer install && npm install

    - name: Generate static files
      run: npm run production

    - name: Deploy 🚀
      uses: JamesIves/github-pages-deploy-action@releases/v3
      with:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        BRANCH: gh-pages # The branch the action should deploy to.
        FOLDER: build_production # The folder the action should deploy.


That's it! This action will build your jigsaw page and push it to your GH-pages branch.

Publishing it to a custom domain

Publishing it is not so difficult. GitHub Pages will automatically generate the default domain for you after you'd run the action the first time. It happens because the action will create a new branch called GH-pages, and GitHub automatically deploys from this branch to your pages-domain: username.github.io/repository.

Now the only manual step: You'll now have to assign the domain you want to use with a CNAME to username.github.io . Then you would have to go to your repository, go to settings, scroll down to "GitHub Pages" and then just enter your custom domain:

After this, you'll see your page live at the configured domain. And after some hours of waiting for the SSL cert you also see your page secured by a https:// suffix.

Do you want to stay up to date?

I'll never spam you, I swear. My newsletter will be send all 2 or 3 weeks with some interesting things for you.

Also you can follow me on twitter where I post recent learnings, hints and comments.

Imprint Data privacy Contact