Skip to content

Commit

Permalink
Merge pull request #11 from marmelab/feat/ci-cd
Browse files Browse the repository at this point in the history
Feat(ops): Add CI/CD pipeline
  • Loading branch information
slax57 authored Aug 5, 2024
2 parents da5bb5d + 322fbf1 commit 336e4b9
Show file tree
Hide file tree
Showing 14 changed files with 394 additions and 236 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ lib
esm
prism.js
packages/create-react-admin/templates/**
.github
5 changes: 2 additions & 3 deletions .eslintrc → .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

{
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand Down Expand Up @@ -30,11 +29,11 @@
],
"no-redeclare": "off",
"import/no-anonymous-default-export": "off",
"@typescript-eslint/no-redeclare": ["error"],
"@typescript-eslint/no-redeclare": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn", // or "error"
{
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: 🚀 Deploy
on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: write
checks: write

jobs:
lint:
name: 🔎 ESLint
runs-on: ubuntu-latest
timeout-minutes: 10
if: ${{ !github.event.pull_request.draft || github.event_name == 'push' }}
steps:
- name: 📥 Checkout repo
uses: actions/checkout@v4

- name: ⚙️ Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: 📥 Download deps
run: npm install

- name: 🔬 Lint
uses: wearerequired/lint-action@v2
with:
eslint: true
eslint_args: "**/*.{mjs,ts,tsx}"
prettier: true
prettier_args: "--config ./.prettierrc.mjs \"**/*.{js,json,ts,tsx,css,md,html}\""

build:
name: 🔨 Build
timeout-minutes: 10
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft || github.event_name == 'push' }}
steps:
- name: 📥 Checkout repo
uses: actions/checkout@v4

- name: ⚙️ Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: 📥 Download deps
run: npm install

- name: 🔨 Build
run: make build
51 changes: 51 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 🚀 Deploy
on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
deploy:
name: 🚀 Deploy
runs-on: ubuntu-latest
timeout-minutes: 10

env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DB_PASSWORD }}
SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}

steps:
- name: 📥 Checkout repo
uses: actions/checkout@v4

- name: ⚙️ Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: ⚙️ Setup supabase
uses: supabase/setup-cli@v1

- name: 📥 Download deps
run: npm install

- name: 🔨 Build
run: make build

- name: 🔗 Supabase Link
run: npx supabase link --project-ref $SUPABASE_PROJECT_ID

- name: 📡 Push supabase migrations
run: npx supabase db push

- name: 📡 Deploy supabase functions
run: npx supabase functions deploy

- name: 📡 Deploy GitHub pages
run: npm run ghpages:deploy
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ cypress/screenshots
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
!.yarn/versions
.github
4 changes: 2 additions & 2 deletions .prettierrc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export default {
singleQuote: true,
tabWidth: 4,
trailingComma: 'es5',
useTabs: false
}
useTabs: false,
};
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,16 @@ make prod-start

Note: It will apply migrations and deploy edge functions.

You can then access the app via [`http://localhost:3000/`](http://localhost:3000/).
You can then access the app via [`http://localhost:3000/`](http://localhost:3000/).


# GitHub Actions

This project supports github actions for continuous integration and delivery. To enable GitHub actions on this repo, you will
have to create the following secrets for the `deploy` environment:

```bash
SUPABASE_ACCESS_TOKEN: Your personal access token, can be found at https://supabase.com/dashboard/account/tokens
SUPABASE_DB_PASSWORD: Your supabase database password
SUPABASE_PROJECT_ID: Your supabase project id
```
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
4 changes: 4 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ supabase-remote-init:
supabase-deploy:
npx supabase db push
npx supabase functions deploy

lint:
npm run lint:check
npm run prettier:check
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@
"dev": "vite --force",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "eslint --ext .js,.ts,.tsx \"./src/**/*.{js,ts,tsx}\"",
"prettier": "prettier --config ./.prettierrc.mjs --write --list-different \"src/**/*.{js,json,ts,tsx,css,md}\"",
"lint:apply": "eslint **/*.{mjs,ts,tsx} --fix",
"lint:check": "eslint **/*.{mjs,ts,tsx}",
"prettier:apply": "prettier --config ./.prettierrc.mjs --write --list-different \"**/*.{js,json,ts,tsx,css,md,html}\"",
"prettier:check": "prettier --config ./.prettierrc.mjs --check \"**/*.{js,json,ts,tsx,css,md,html}\"",
"ghpages:deploy": "node ./scripts/ghpages-deploy.mjs",
"supabase:remote:init": "node ./scripts/supabase-remote-init.mjs"
}
Expand Down
Loading

0 comments on commit 336e4b9

Please sign in to comment.