name: publish

on:
  push:
    branch:
      - "main"

jobs:
  publish-site:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v1

      - name: Setup git
        run: |
          git config --global user.email "mpippi@gmail.com"
          git config --global user.name "masci"
          git remote add upstream https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git

      - name: Build site
        uses: jakejarvis/hugo-build-action@master
        with:
          args: -s site

      - name: Push gh-pages branch
        run: |
          git add -A
          git commit -m"rebuilding site from ${{ github.sha }}"
          git push upstream `git subtree split --prefix=site/public --ignore-joins`:gh-pages --force

name: publish

on:
  push:
    branch:
      - $default-branch

jobs:
  publish-site:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v1

      - name: Setup git
        run: |
          git config --global user.email "mpippi@gmail.com"
          git config --global user.name "masci"
          git remote add upstream https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git

      - name: Build site
        uses: jakejarvis/hugo-build-action@master
        with:
          args: -s site

      - name: Push gh-pages branch
        run: |
          git add -A
          git commit -m"rebuilding site from ${{ github.sha }}"
          git push upstream `git subtree split --prefix=site/public --ignore-joins`:gh-pages --force

Use $default-branch instead of the name of the branch
Use $default-branch instead of the name of the branch