-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add automated deployment workflow for prod branch #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,113 @@ | ||||||||
| name: Deploy to Production | ||||||||
|
|
||||||||
| on: | ||||||||
| push: | ||||||||
| branches: [prod] | ||||||||
|
|
||||||||
| jobs: | ||||||||
| test: | ||||||||
| runs-on: ubuntu-24.04 | ||||||||
|
|
||||||||
| steps: | ||||||||
| - name: Checkout code | ||||||||
| uses: actions/checkout@v5 | ||||||||
|
|
||||||||
| - name: Enable corepack | ||||||||
| run: corepack enable | ||||||||
|
|
||||||||
| - name: Setup Node.js | ||||||||
| uses: actions/setup-node@v5 | ||||||||
| with: | ||||||||
| node-version-file: ".node-version" | ||||||||
| cache: "pnpm" | ||||||||
| cache-dependency-path: "pnpm-lock.yaml" | ||||||||
|
|
||||||||
| - name: Install dependencies | ||||||||
| run: pnpm install --frozen-lockfile | ||||||||
|
|
||||||||
| - name: Run tests | ||||||||
| run: pnpm test:run | ||||||||
|
|
||||||||
| - name: Run linter (without build artifacts) | ||||||||
| run: rm -rf dist && rm -f hono/static/*.js hono/static/*.js.map && pnpm lint | ||||||||
|
|
||||||||
| - name: Run build | ||||||||
| run: pnpm build | ||||||||
|
|
||||||||
| e2e: | ||||||||
| runs-on: ubuntu-24.04 | ||||||||
|
|
||||||||
| steps: | ||||||||
| - name: Checkout code | ||||||||
| uses: actions/checkout@v5 | ||||||||
|
|
||||||||
| - name: Enable corepack | ||||||||
| run: corepack enable | ||||||||
|
|
||||||||
| - name: Setup Node.js | ||||||||
| uses: actions/setup-node@v5 | ||||||||
| with: | ||||||||
| node-version-file: ".node-version" | ||||||||
| cache: "pnpm" | ||||||||
| cache-dependency-path: "pnpm-lock.yaml" | ||||||||
|
|
||||||||
| - name: Install dependencies | ||||||||
| run: pnpm install --frozen-lockfile | ||||||||
|
|
||||||||
| - name: Install Playwright Browsers | ||||||||
| run: pnpm exec playwright install --with-deps chromium | ||||||||
|
|
||||||||
| - name: Build JavaScript files | ||||||||
| run: pnpm build | ||||||||
|
|
||||||||
| - name: Run database migrations | ||||||||
| run: pnpm db:migrate | ||||||||
|
|
||||||||
| - name: Seed database | ||||||||
| run: pnpm db:seed | ||||||||
|
|
||||||||
| - name: Run Playwright tests | ||||||||
| env: | ||||||||
| SESSION_SECRET: ${{ secrets.SESSION_SECRET }} | ||||||||
| E2E_GMAIL_ACCOUNT: ${{ secrets.E2E_GMAIL_ACCOUNT }} | ||||||||
| E2E_GMAIL_PASSWORD: ${{ secrets.E2E_GMAIL_PASSWORD }} | ||||||||
| run: pnpm test:e2e | ||||||||
|
|
||||||||
| - name: Upload test artifacts | ||||||||
| uses: actions/upload-artifact@v5 | ||||||||
| if: failure() | ||||||||
| with: | ||||||||
| name: playwright-report | ||||||||
| path: playwright-report/ | ||||||||
| retention-days: 30 | ||||||||
|
|
||||||||
| deploy: | ||||||||
| needs: [test, e2e] | ||||||||
|
||||||||
| needs: [test, e2e] | |
| needs: [test, e2e] | |
| environment: production |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a
concurrencygroup for this workflow (or at least for thedeployjob) to prevent overlapping production deploys. Without concurrency/cancel-in-progress, two quick pushes toprodcan run two deploy jobs in parallel and the older run may finish last, effectively redeploying an older commit after a newer one.