update readme #39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push to Build Branch | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| environment: production | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| ports: | |
| - 5432:5432 | |
| env: | |
| POSTGRES_DB: payload | |
| POSTGRES_USER: payload | |
| POSTGRES_PASSWORD: payload | |
| options: >- | |
| --health-cmd="pg_isready -U payload" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=5 | |
| env: | |
| DATABASE_URL: postgres://payload:payload@localhost:5432/payload | |
| AWS_SERVICE_REGION: ${{ vars.AWS_SERVICE_REGION }} | |
| AWS_ACCESS_KEY: ${{ vars.AWS_ACCESS_KEY }} | |
| EMAIL_DEFAULT_FROM_NAME: ${{ vars.EMAIL_DEFAULT_FROM_NAME }} | |
| EMAIL_DEFAULT_FROM_NO_REPLY: ${{ vars.EMAIL_DEFAULT_FROM_NO_REPLY }} | |
| EMAIL_DEFAULT_FROM_HI: ${{ vars.EMAIL_DEFAULT_FROM_HI }} | |
| EMAIL_DEFAULT_REPLY_TO: ${{ vars.EMAIL_DEFAULT_REPLY_TO }} | |
| AWS_ACCESS_SECRET: ${{ secrets.AWS_ACCESS_SECRET }} | |
| PAYLOAD_SECRET: ${{ secrets.PAYLOAD_SECRET }} | |
| steps: | |
| - name: Checkout source | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| cache: true | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Migrate database | |
| run: pnpm payload migrate | |
| - name: Build | |
| env: | |
| NODE_OPTIONS: --max-old-space-size=4096 | |
| run: pnpm build | |
| - name: Prepare build branch | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| # 拷贝 .next 但排除 cache | |
| # rsync -av --exclude='cache' .next/ /tmp/next-build/ | |
| rm -rf .next/cache | |
| mkdir -p /tmp/next-build | |
| cp -r .next/* /tmp/next-build/ | |
| # 切换或创建 build 分支 | |
| git checkout -B build | |
| # 清空分支 | |
| git rm -rf . | |
| # 把 build 产物拷进去(按需修改) | |
| # rsync -av /tmp/next-build/ .next/ | |
| rm -rf .next | |
| mkdir -p .next | |
| cp -r /tmp/next-build/* .next/ | |
| git add .next | |
| git commit -m "chore: build from $GITHUB_SHA" | |
| git push -f origin build |