# Workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
  push:
    branches: ["main"]
  workflow_dispatch:

# Set permissions for GitHub Pages deployment
permissions:
  contents: read
  pages: write
  id-token: write

# Limit to one concurrent deployment
concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  # Build and deploy job
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repository
        uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Cache node_modules
        uses: actions/cache@v3
        with:
          path: node_modules
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - name: Build static content
        run: npm run build

      - name: Configure GitHub Pages
        uses: actions/configure-pages@v4

      - name: Upload static content artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: './dist'  # Uygunsa build çıktısı dizininizi buraya yazın (örneğin: public, build, dist)

      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4
