name: Firestore Backup

on:
  schedule:
    # 매일 한국 시간 오전 04:00 (UTC 19:00)
    - cron: '0 19 * * *'
  workflow_dispatch: # 수동 실행 지원

jobs:
  backup:
    runs-on: ubuntu-latest
    permissions:
      contents: 'read'
      id-token: 'write'

    steps:
      - uses: actions/checkout@v4

      - id: 'auth'
        uses: 'google-github-actions/auth@v2'
        with:
          credentials_json: '${{ secrets.GCP_SA_KEY }}'

      - name: 'Set up Cloud SDK'
        uses: 'google-github-actions/setup-gcloud@v2'

      - name: 'Export Firestore to GCS'
        run: |
          gcloud firestore export gs://${{ secrets.GCS_BUCKET_NAME }}
