# This workflow runs when changes to examples are pushed to main.
# It calls a build hook on Netlify that will redeploy preview.astro.new with the latest changes.

name: Redeploy preview.astro.new

on:
  push:
    branches: 
      - main
    paths: 
      - 'examples/**'
  workflow_dispatch:

jobs:
  deploy:
    if: ${{ github.repository_owner == 'withastro' }}
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - name: Send a POST request to Netlify to rebuild preview.astro.new
        run: 'curl -X POST -d {} ${BUILD_HOOK}'
        env:
          BUILD_HOOK: ${{ secrets.NETLIFY_PREVIEWS_BUILD_HOOK }}
