name: Build And Save Log on: push: branches: - main pull_request: branches: - main jobs: build: runs-on: ubuntu-latest services: # Menjalankan PostgreSQL sebagai service di GitHub Actions postgres: image: postgres:14 env: POSTGRES_USER: ${{ secrets.POSTGRES_USER }} POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} POSTGRES_DB: ${{ secrets.POSTGRES_DB }} ports: - 5432:5432 options: >- --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=5 steps: # Checkout kode sumber - name: Checkout code uses: actions/checkout@v3 # Setup Bun - name: Setup Bun uses: oven-sh/setup-bun@v1 # Install dependencies - name: Install dependencies run: bun install # Konfigurasi environment variable untuk PostgreSQL dan variabel tambahan - name: Set up environment variables run: | echo "DATABASE_URL=postgresql://${{ secrets.POSTGRES_USER }}:${{ secrets.POSTGRES_PASSWORD }}@localhost:5432/${{ secrets.POSTGRES_DB }}?schema=public" >> .env echo "PORT=${{ secrets.PORT }}" >> .env echo "NEXT_PUBLIC_WIBU_URL=${{ secrets.NEXT_PUBLIC_WIBU_URL }}" >> .env echo "WIBU_UPLOAD_DIR=${{ secrets.WIBU_UPLOAD_DIR }}" >> .env # Migrasi database menggunakan Prisma - name: Apply Prisma schema to database run: bun prisma db push # Seed database (opsional) - name: Seed database run: bun prisma db seed # Build project - name: Build project run: bun run build # Download GitHub Actions logs - name: Download GitHub Actions logs run: | mkdir -p logs curl -H "Authorization: token ${{ secrets.WIBU_GITHUB_TOKEN }}" \ -L "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/logs" \ -o logs.zip # Send email with GitHub Actions logs - name: Send email with logs uses: dawidd6/action-send-mail@v3 with: server_address: smtp.gmail.com server_port: 587 username: ${{ secrets.GMAIL_USERNAME }} password: ${{ secrets.GMAIL_APP_PASSWORD }} subject: "GitHub Actions Logs" body: | The deployment process has completed successfully. Please find the attached GitHub Actions logs. to: kurosakiblackangel@gmail.com from: bip.production.js@gmail.com attachments: | ${{ github.workspace }}/logs.zip