name: update-dev-branch

# This is used to sync the `dev` branch with the `main` branch to continuously
# deploy a second instance of the app to Vercel: https://app.dev.zoo.dev

on:
  push:
    branches:
      - main
    pull_request:
      paths:
        - .github/workflows/update-dev-branch.yml

permissions:
  contents: write

jobs:
  update-branch:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - shell: bash
        run: |
          # checkout our branch
          git checkout dev || git checkout -b dev
          # fetch origin
          git fetch origin
          # reset to main
          git reset --hard origin/main
          # force push it
          git push --force origin dev
