Skip to content

Commit

Permalink
remove all prisma-related things and improve deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Oct 9, 2023
1 parent 630fb82 commit ef42282
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 151 deletions.
101 changes: 15 additions & 86 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ jobs:
- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: 🖼 Build icons
run: npm run build:icons

- name: 🔬 Lint
run: npm run lint
Expand All @@ -45,113 +46,41 @@ jobs:
- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: 📥 Download deps
uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: 🖼 Build icons
run: npm run build:icons

- name: 🔎 Type check
run: npm run typecheck --if-present

build:
name: 🐳 Build
# only build/deploy main branch on pushes
if:
${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') &&
github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 👀 Read app name
uses: SebRollen/[email protected]
id: app_name
with:
file: 'fly.toml'
field: 'app'

- name: 🐳 Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Setup cache
- name: ⚡️ Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: 🔑 Fly Registry Auth
uses: docker/login-action@v2
with:
registry: registry.fly.io
username: x
password: ${{ secrets.FLY_API_TOKEN }}

- name: 🐳 Docker build
uses: docker/build-push-action@v3
with:
context: .
push: true
tags:
registry.fly.io/${{ steps.app_name.outputs.value }}:${{
github.ref_name }}-${{ github.sha }}
build-args: |
COMMIT_SHA=${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

# This ugly bit is necessary if you don't want your cache to grow forever
# till it hits GitHub's limit of 5GB.
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: 🚚 Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
deploy:
name: 🚀 Deploy
runs-on: ubuntu-latest
needs: [lint, typecheck, build]
needs: [lint, typecheck]
# only build/deploy main branch on pushes
if:
${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') &&
github.event_name == 'push' }}
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}

steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 👀 Read app name
uses: SebRollen/[email protected].0
uses: SebRollen/[email protected].2
id: app_name
with:
file: 'fly.toml'
field: 'app'

- name: 🚀 Deploy Staging
if: ${{ github.ref == 'refs/heads/dev' }}
uses: superfly/[email protected]
with:
args:
'deploy --app ${{ steps.app_name.outputs.value }}-staging --image
registry.fly.io/${{ steps.app_name.outputs.value }}:${{
github.ref_name }}-${{ github.sha }}'
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
- name: 🎈 Setup Fly
uses: superfly/flyctl-actions/[email protected]

- name: 🚀 Deploy Production
if: ${{ github.ref == 'refs/heads/main' }}
uses: superfly/[email protected]
with:
args:
'deploy --image registry.fly.io/${{ steps.app_name.outputs.value
}}:${{ github.ref_name }}-${{ github.sha }}'
run:
flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ node_modules
/public/build-info.json
.env

/prisma/data.db
/prisma/data.db-journal

/app/styles/tailwind.css

/app/bot/playground.ts
51 changes: 0 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"format": "prettier --write .",
"generate:css": "tailwindcss -o ./app/styles/tailwind.css",
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
"setup": "prisma generate && prisma migrate deploy && prisma db seed",
"start": "cross-env NODE_ENV=production remix-serve build",
"start:mocks": "binode --require ./mocks -- @remix-run/serve:remix-serve build",
"typecheck": "tsc -b",
Expand Down Expand Up @@ -48,7 +47,6 @@
"dependencies": {
"@discordjs/builders": "^1.2.0",
"@discordjs/rest": "^1.2.0",
"@prisma/client": "^4.4.0",
"@remix-run/node": "^1.7.2",
"@remix-run/react": "^1.7.2",
"@remix-run/serve": "^1.7.2",
Expand Down Expand Up @@ -103,7 +101,6 @@
"postcss": "^8.4.16",
"prettier": "2.7.1",
"prettier-plugin-tailwindcss": "^0.1.13",
"prisma": "^4.4.0",
"start-server-and-test": "^1.14.0",
"tailwindcss": "^3.1.8",
"ts-node": "^10.9.1",
Expand All @@ -112,8 +109,5 @@
},
"engines": {
"node": "18"
},
"prisma": {
"seed": "node --require tsconfig-paths/register prisma/seed.js"
}
}
5 changes: 0 additions & 5 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/bin/sh

# This file is how Fly starts the server (configured in fly.toml). Before starting
# the server though, we need to run any prisma migrations that haven't yet been
# run, which is why this file exists in the first place.
# Learn more: https://community.fly.io/t/sqlite-not-getting-setup-properly/4386

set -ex
# node ./scripts/deploy-commands.js
# node ./scripts/deploy-emoji.js
Expand Down

0 comments on commit ef42282

Please sign in to comment.