Deploying a static site using Publish on Github Pages


We'll assume you know how to use Xcode to work with Swift packages and how to push code to GitHub, other than that you should learn all the required skills, to publish your own static website, in this post.

To get up and running with your own static site please follow the instructions on how to install Publish here.

Once done with this let's spin up a site using

$ mkdir MyWebsite
$ cd MyWebsite
$ publish new
$ open Package.swift

You'll now be greated by Xcode and able to add some content to your site and adjust your template, going deeper into details on how to customize the site or add content would exceed this post, so we're going to jump right onto deploying your site.

To deploy your site using GitHub Actions you're going to need a Workflow, let's get going with some that'll build your site and deploy it to your personal GitHub User.

Adding a GitHub Workflow

Please take a look at the following GitHub Workflow:

name: Build and Deploy MyWebsite

      - main

    runs-on: ubuntu-18.04
      - name: Checkout Source
        uses: actions/checkout@v1
      - name: Build Site
        run: swift run MyWebsite
      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
            github_token: ${{ secrets.GITHUB_TOKEN }}
            publish_dir: ./Output

This code needs to go into your repository at .github/workflows/deploy.yml.

There's a few things you'd need to adust, please replace MyWebsite by the name you've picked when creating your site in the first place. GITHUB_TOKEN will be automatically populated.

Deploying your site

Please create a repository named, commit the code with your deploy.yml and, once pushed, this will deploy the build artifacts from ./Output to a gh-pages branch which will then be accessible at

That's it!

Using your own custom domain

If you'd like to use your own custom domain, you need a CNAME file containing this domain, e.g.

To achieve this, just add the following property to the Deploy step of your deploy.yml:

       - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
            github_token: ${{ secrets.GITHUB_TOKEN }}
            publish_dir: ./Output

Then set up a CNAME record pointing from your my-website subdomain to, e.g.:

my-website 10800 IN CNAME