diff --git a/.github/workflows/heat-stack.yml b/.github/workflows/heat-stack.yml index 140bfd2e..9ba2f582 100644 --- a/.github/workflows/heat-stack.yml +++ b/.github/workflows/heat-stack.yml @@ -3,7 +3,8 @@ on: push: branches: - main - # - dev + - gha-deployment + - dev pull_request: {} env: @@ -24,7 +25,7 @@ permissions: jobs: lint: name: ⬣ ESLint - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: ⬇️ Checkout repo uses: actions/checkout@v3 @@ -50,7 +51,7 @@ jobs: typecheck: name: ʦ TypeScript - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: ⬇️ Checkout repo uses: actions/checkout@v3 @@ -73,7 +74,7 @@ jobs: vitest: name: ⚡ Vitest pyodide.test.ts - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: ⬇️ Checkout repo uses: actions/checkout@v3 @@ -100,7 +101,7 @@ jobs: # playwright tests work great but slight jank/inconsistency passing, and not used yet, so disabling for now # playwright: # name: 🎭 Playwright - # runs-on: ubuntu-latest + # runs-on: ubuntu-22.04 # timeout-minutes: 60 # steps: # - name: ⬇️ Checkout repo @@ -155,46 +156,46 @@ jobs: # path: playwright-report/ # retention-days: 30 - # deploy: - # name: 🚀 Deploy - # runs-on: ubuntu-latest - # needs: [lint, typecheck, vitest, playwright] - # # only build/deploy main branch on pushes - # if: - # ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && - # github.event_name == 'push' }} + deploy: + name: 🚀 Deploy + runs-on: ubuntu-latest + needs: [lint, typecheck, vitest] #, playwright] + # only build/deploy main branch on pushes + if: + ${{ (github.ref == 'refs/heads/gha-deployment' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && + github.event_name == 'push' }} - # steps: - # - name: ⬇️ Checkout repo - # uses: actions/checkout@v3 + steps: + - name: ⬇️ Checkout repo + uses: actions/checkout@v3 - # - name: 👀 Read app name - # uses: SebRollen/toml-action@v1.0.2 - # id: app_name - # with: - # file: 'fly.toml' - # field: 'app' - - # # move Dockerfile to root - # - name: 🚚 Move Dockerfile - # run: | - # mv ./other/Dockerfile ./Dockerfile - # mv ./other/.dockerignore ./.dockerignore - - # - name: 🎈 Setup Fly - # uses: superfly/flyctl-actions/setup-flyctl@v1.4 - - # - name: 🚀 Deploy Staging - # if: ${{ github.ref == 'refs/heads/dev' }} - # run: - # flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }} - # --app ${{ steps.app_name.outputs.value }}-staging - # env: - # FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} - - # - name: 🚀 Deploy Production - # if: ${{ github.ref == 'refs/heads/main' }} - # run: - # flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }} - # env: - # FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} + - name: 👀 Read app name + uses: SebRollen/toml-action@v1.0.2 + id: app_name + with: + file: '${{ env.working-directory }}/fly.toml' + field: 'app' + + # move Dockerfile to root + - name: 🚚 Move Dockerfile + run: | + mv ./other/Dockerfile ./Dockerfile + mv ./other/.dockerignore ./.dockerignore + + - name: 🎈 Setup Fly + uses: superfly/flyctl-actions/setup-flyctl@v1.4 + + - name: 🚀 Deploy Staging + if: ${{ github.ref == 'refs/heads/dev' }} + run: + flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }} + --app ${{ steps.app_name.outputs.value }}-staging + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} + + - name: 🚀 Deploy Production + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/gha-deployment' }} + run: + flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }} + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} diff --git a/.gitignore b/.gitignore index 5e16b5c7..ee899313 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,8 @@ node_modules # Easy way to create temporary files/folders that won't accidentally be added to git *.local.* + +#local temporary folders +heat-app +venv +heat-tmp \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..7619ac2b --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,11 @@ +{ + "recommendations": [ + "bradlc.vscode-tailwindcss", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "prisma.prisma", + "qwtel.sqlite-viewer", + "yoavbls.pretty-ts-errors", + "github.vscode-github-actions" + ] +} diff --git a/heat-stack/.env.example b/heat-stack/.env.example index d117323c..46659864 100644 --- a/heat-stack/.env.example +++ b/heat-stack/.env.example @@ -3,6 +3,7 @@ DATABASE_PATH="./prisma/data.db" DATABASE_URL="file:./data.db?connection_limit=1" CACHE_DATABASE_PATH="./other/cache.db" SESSION_SECRET="super-duper-s3cret" +HONEYPOT_SECRET="super-duper-s3cret" INTERNAL_COMMAND_TOKEN="some-made-up-token" RESEND_API_KEY="re_blAh_blaHBlaHblahBLAhBlAh" SENTRY_DSN="your-dsn" diff --git a/heat-stack/README.md b/heat-stack/README.md index a63d17af..60a8605b 100644 --- a/heat-stack/README.md +++ b/heat-stack/README.md @@ -17,6 +17,7 @@ npm install npm run dev ``` + ### Set up in a new GitHub CodingSpace: ``` @@ -30,6 +31,9 @@ npm run dev If you have the node version manager (`nvm`), then `nvm use 18` avoids engine error with node v19+ or newer which is default. nvm is preinstalled in coding spaces. + +In Coding Spaces VSCode always go to hamburger menu -> File-> untick AutoSave. For a pic, see https://stackoverflow.com/a/76659316/14144258 + ### Under special circumstances: Assume you don't need to, but if the version of pyodide changes run: diff --git a/heat-stack/app/components/confetti.tsx b/heat-stack/app/components/confetti.tsx deleted file mode 100644 index 69fbecef..00000000 --- a/heat-stack/app/components/confetti.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { Index as ConfettiShower } from 'confetti-react' -import { ClientOnly } from 'remix-utils' - -export function Confetti({ id }: { id?: string | null }) { - if (!id) return null - - return ( - - {() => ( - - )} - - ) -} diff --git a/heat-stack/app/components/error-boundary.tsx b/heat-stack/app/components/error-boundary.tsx index 12175f31..80c1406b 100644 --- a/heat-stack/app/components/error-boundary.tsx +++ b/heat-stack/app/components/error-boundary.tsx @@ -1,9 +1,10 @@ import { + type ErrorResponse, isRouteErrorResponse, useParams, useRouteError, } from '@remix-run/react' -import { type ErrorResponse } from '@remix-run/router' +import { captureRemixErrorBoundaryError } from '@sentry/remix' import { getErrorMessage } from '#app/utils/misc.tsx' type StatusHandler = (info: { @@ -25,6 +26,7 @@ export function GeneralErrorBoundary({ unexpectedErrorHandler?: (error: unknown) => JSX.Element | null }) { const error = useRouteError() + captureRemixErrorBoundaryError(error) const params = useParams() if (typeof document !== 'undefined') { diff --git a/heat-stack/app/components/forms.tsx b/heat-stack/app/components/forms.tsx index 0d362fcb..ad2868ad 100644 --- a/heat-stack/app/components/forms.tsx +++ b/heat-stack/app/components/forms.tsx @@ -19,7 +19,7 @@ export function ErrorList({ return (