name: Pages Redirect

on:
  workflow_dispatch:

permissions:
  pages: write
  id-token: write
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Create redirect page
        run: |
          mkdir site
          cat <<EOF > site/index.html
          <!DOCTYPE html>
          <html>
          <head>
            <meta charset="utf-8">
            <meta http-equiv="refresh" content="0; url=https://community-scripts.org/">
            <link rel="canonical" href="https://community-scripts.org/">
            <title>Redirecting...</title>
          </head>
          <body>
            Redirecting...
          </body>
          </html>
          EOF

      - uses: actions/upload-pages-artifact@v3
        with:
          path: site

      - name: Deploy
        uses: actions/deploy-pages@v4
