name: Deploy Airse

on:
  push:
    branches: [main]
    paths:
      - 'icon/**'
      - 'rse/**'
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      deployments: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - name: Copy icons
        run: mkdir -p rse/public/service && cp icon/ai.syui.at.png icon/ai.syui.card.png icon/ai.syui.rse.png rse/public/service/
      - run: npm install
        working-directory: rse
      - run: npm run build
        working-directory: rse
      - uses: cloudflare/pages-action@v1
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          projectName: ${{ secrets.APP_RSE_NAME }}
          directory: rse/dist
          gitHubToken: ${{ secrets.GITHUB_TOKEN }}
          wranglerVersion: '3'
