name: Angular Build

on:
  push:
    branches:
      - dev

jobs:
  build:
    runs-on: runner
    container:
      image: node:20-bullseye

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install dependencies
        run: npm ci -f

      - name: Create firebase.ts
        run: |
          mkdir -p src/app
          cat > src/environments/firebase.ts <<'EOF'
          export const firebase = {
            apiKey: "${{ secrets.FIREBASE_API_KEY }}",
            authDomain: "${{ secrets.FIREBASE_AUTH_DOMAIN }}",
            databaseURL: 'https://worshipgenerator.firebaseio.com',
            projectId: "${{ secrets.FIREBASE_PROJECT_ID }}",
            storageBucket: "${{ secrets.FIREBASE_STORAGE_BUCKET }}",
            messagingSenderId: "${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}",
            appId: "${{ secrets.FIREBASE_APP_ID }}"
          };
          EOF

      - name: Build Angular
        run: npm run build
