瀏覽代碼

Fix: align ci with dockerfile (#51)

* ci(github): align workflow with Dockerfile and add optimizations

* feat: add pull request template

* fix(ci): update pnpm to v9 to match lockfile version

* fix(ci): add required environment variables for build
Adrien 1 月之前
父節點
當前提交
540f57ae5d
共有 3 個文件被更改,包括 99 次插入6 次删除
  1. 0 0
      .github/ISSUE_TEMPLATE/pull_request_template.md
  2. 30 0
      .github/pull_request_template.md
  3. 69 6
      .github/workflows/ci.yml

+ 0 - 0
.github/ISSUE_TEMPLATE/pull_request_template.md


+ 30 - 0
.github/pull_request_template.md

@@ -0,0 +1,30 @@
+## 📝 Description
+
+<!-- Briefly describe the changes made -->
+
+## 🧪 Testing
+
+- [ ] I have tested my changes locally
+- [ ] Existing tests pass
+- [ ] I have added tests if necessary
+
+## 📋 Checklist
+
+- [ ] My code follows the project conventions
+- [ ] I have checked for linting errors
+- [ ] The build passes without errors
+- [ ] This PR includes breaking changes
+- [ ] I have updated documentation if necessary
+
+## 🗃️ Prisma Migrations (if applicable)
+
+- [ ] I have created a migration
+- [ ] I have tested the migration locally
+
+## 📸 Screenshots (if applicable)
+
+<!-- Add screenshots for visual changes -->
+
+## 🔗 Related Issues
+
+<!-- Reference issues: Closes #123, Fixes #456 --> 

+ 69 - 6
.github/workflows/ci.yml

@@ -10,20 +10,83 @@ jobs:
   lint:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
 
       - name: Setup Node.js
-        uses: actions/setup-node@v3
+        uses: actions/setup-node@v4
         with:
-          node-version: "18"
+          node-version: "20"
 
       - name: Setup pnpm
-        uses: pnpm/action-setup@v2
+        uses: pnpm/action-setup@v4
         with:
-          version: 8
+          version: 9
+
+      - name: Get pnpm store directory
+        shell: bash
+        run: |
+          echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
+
+      - name: Setup pnpm cache
+        uses: actions/cache@v4
+        with:
+          path: ${{ env.STORE_PATH }}
+          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
+          restore-keys: |
+            ${{ runner.os }}-pnpm-store-
 
       - name: Install dependencies
-        run: pnpm install
+        run: pnpm install --frozen-lockfile
+
+      - name: Generate Prisma client
+        run: pnpm prisma generate
 
       - name: Run linting
         run: pnpm lint
+
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: Setup Node.js
+        uses: actions/setup-node@v4
+        with:
+          node-version: "20"
+
+      - name: Setup pnpm
+        uses: pnpm/action-setup@v4
+        with:
+          version: 9
+
+      - name: Get pnpm store directory
+        shell: bash
+        run: |
+          echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
+
+      - name: Setup pnpm cache
+        uses: actions/cache@v4
+        with:
+          path: ${{ env.STORE_PATH }}
+          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
+          restore-keys: |
+            ${{ runner.os }}-pnpm-store-
+
+      - name: Install dependencies
+        run: pnpm install --frozen-lockfile
+
+      - name: Generate Prisma client
+        run: pnpm prisma generate
+
+      - name: Build project
+        run: pnpm build
+        env:
+          BETTER_AUTH_URL: http://localhost:3000
+          DATABASE_URL: postgresql://user:password@localhost:5432/test_db
+          GOOGLE_CLIENT_ID: test_client_id
+          GOOGLE_CLIENT_SECRET: test_client_secret
+          RESEND_API_KEY: re_test_key
+          BETTER_AUTH_SECRET: test_secret_key_32_chars_minimum
+          OPENPANEL_SECRET_KEY: test_secret
+          NEXT_PUBLIC_OPENPANEL_CLIENT_ID: test_client_id
+          NEXT_PUBLIC_FACEBOOK_PIXEL_ID: 123456789