name: Refresh staging

# Rebuilds the pms1 staging instance (pm2 `ppms-staging`, port 3200) to the latest
# master on every merge to master, so staging always mirrors the trunk for
# smoke-testing before a release tag. Also runnable on demand (workflow_dispatch).
# See automation/README.md > "Staging".

on:
  push:
    branches: [master]
  workflow_dispatch: {}

# Only one staging refresh at a time; a newer master push cancels an in-flight build
# (staging-up.sh always checks out the latest origin/master, so the newest wins).
concurrency:
  group: refresh-staging
  cancel-in-progress: true

jobs:
  refresh:
    runs-on: host
    steps:
      - name: Rebuild staging on latest master
        run: |
          set -e
          export NVM_DIR="$HOME/.nvm"; . "$NVM_DIR/nvm.sh"
          "$HOME/issue-watcher/staging-up.sh"
