Like any software engineer, I strive to be two things: cheap and lazy. That’s why I manage this site (and several others) through free hosting services such as and a static site generator, such as Hugo. Until recently, I’ve used Surge’s CLI to deploy changes, but I’ve now switched to Github Workflows to deploy changes automagically.

Here is my workflow for publishing to surge with Github Workflows:

# This is a basic workflow that is manually triggered

name: Publish to Surge

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
        description: Git SHA-1 Ref (Optional)    
        required: false

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
    - name: Clone Repository (Latest)
      uses: actions/[email protected]
      if: github.event.inputs.git-ref == ''
    - name: Clone Repository (Custom Ref)
      uses: actions/[email protected]
      if: github.event.inputs.git-ref != ''
        ref: ${{ github.event.inputs.git-ref }}
    - name: Hugo setup
      # You may pin to the exact commit or the version.
      # uses: peaceiris/[email protected]
      uses: peaceiris/[email protected]
        # The Hugo version to download (if necessary) and use. Example: 0.58.2
        hugo-version: latest
        # Download (if necessary) and use Hugo extended version. Example: true
        extended: true
    - name: Generate static files
      run: cd <HUGO_APP> && hugo -D
    - name: Publish to
      # You may pin to the exact commit or the version.
      # uses: dswistowski/[email protected]
      uses: dswistowski/[email protected]
        # your domain to deploy
        domain: <YOUR_DOMAIN_NAME>
        # login
        login: <YOUR_EMAIL>
        # token, generate it with `surge token` command
        token: <TOKEN>
        # your project path
        project: <PATH_TO_YOUR_PROJECT>