Skip to content

Commit

Permalink
feat: rewrite as Next.js app (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahsnider authored Aug 29, 2023
1 parent 9509ca1 commit fb32952
Show file tree
Hide file tree
Showing 216 changed files with 4,865 additions and 15,221 deletions.
8 changes: 0 additions & 8 deletions .changeset/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions .changeset/config.json

This file was deleted.

24 changes: 0 additions & 24 deletions .devcontainer/devcontainer.json

This file was deleted.

43 changes: 0 additions & 43 deletions .devcontainer/docker-compose.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .do/deploy.template.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions .dockerignore

This file was deleted.

143 changes: 32 additions & 111 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,137 +2,58 @@ name: CI

on: [push, pull_request]

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

jobs:
docker-build:
name: Build Docker image
build:
name: Build

runs-on: ubuntu-latest

timeout-minutes: 10
timeout-minutes: 5

steps:
- name: Checkout git repository
- name: Checkout Git repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
node-version: "18"
cache: "yarn"
- name: Install dependencies with Yarn
run: yarn install --immutable
- name: Pull latest image
run: docker pull zwsim/zws:latest
- name: Build Docker image
# run: docker buildx build --pull --tag zwsim/zws:latest --platform linux/amd64,linux/arm64 .
run: docker buildx build --pull --tag zwsim/zws:latest --platform linux/amd64 .
test:
name: Test

runs-on: ubuntu-latest

timeout-minutes: 15

services:
postgres:
image: postgres:15
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: password
POSTGRES_DB: zws
ports:
- '5432:5432'
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout git repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
- name: Pull environment variables
run: yarn vercel env pull --environment development .env --token ${{ secrets.VERCEL_TOKEN }}
- name: Cache Next.js
uses: actions/cache@v3
with:
node-version: '16'
cache: 'yarn'
- name: Install dependencies with Yarn
run: yarn install --immutable
- name: Run migrations
run: yarn run migrations
env:
DATABASE_URL: postgres://test:password@localhost:5432/zws
- name: Run tests
run: yarn test
env:
SMOKE_TEST: true
DATABASE_URL: postgres://test:password@localhost:5432/zws
timeout-minutes: 5
lint-dockerfile:
name: Lint Dockerfile
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Build
run: yarn run build
lint:
name: Lint

runs-on: ubuntu-latest

timeout-minutes: 5

steps:
- name: Checkout git repository
uses: actions/checkout@v3
- name: Lint Dockerfile
uses: hadolint/[email protected]
with:
dockerfile: Dockerfile
deploy:
name: Deploy

runs-on: ubuntu-latest

timeout-minutes: 30

# Don't run this job if we aren't on main branch
if: ${{ github.ref == 'refs/heads/main' }}

needs: [test, docker-build, lint-dockerfile]

steps:
- name: Checkout git repository
- name: Checkout Git repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
node-version: "18"
cache: "yarn"
- name: Install dependencies with Yarn
run: yarn install --immutable
- name: Build
run: yarn run build
- name: Setup Git for committing
run: |
git config --global user.email "[email protected]"
git config --global user.name "zws.im"
git remote add github "https://[email protected]/$GITHUB_REPOSITORY.git"
git fetch github
- name: Configure npm
run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Update versions with changesets
run: yarn changeset version
- name: Publish with changesets
run: |
yarn changeset publish
git add -A
# Exit succesfully if no changes
git commit -m "build: release" || exit 0
git push --follow-tags -u github main
env:
# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Lint
run: yarn run lint
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,5 @@ $RECYCLE.BIN/
*.env
!*example.env

# Google Cloud Service account
service-account-key.json

# Turbo
.turbo
# Vercel
.vercel
Loading

0 comments on commit fb32952

Please sign in to comment.