Skip to content

Commit

Permalink
Add CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmanMazdaee committed Aug 13, 2024
1 parent 178cfdb commit d9a6ea4
Show file tree
Hide file tree
Showing 11 changed files with 6,846 additions and 1,276 deletions.
11 changes: 11 additions & 0 deletions .github/actions/check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "Check"
description: "Run Checks"
runs:
using: "composite"
steps:
- name: Setup
uses: ./.github/actions/setup

- name: Run Checks
shell: bash
run: npm run check
17 changes: 17 additions & 0 deletions .github/actions/deploy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Deploy"
description: "Deploy Apps"
runs:
using: "composite"
steps:
- name: Setup
uses: ./.github/actions/setup

- name: Run Build
shell: bash
run: npm run build

- name: Deploy To Cloudflare
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
workingDirectory: "apps/web"
22 changes: 22 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Setup"
description: "Setup the dependencies"
runs:
using: "composite"
steps:
- name: Cache Turbo Build Setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-release-job-${{ github.sha }}
restore-keys: |
${{ runner.os }}-release-job-
- name: Setup Node.js Environment
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- name: Install Dependencies
shell: bash
run: npm install
11 changes: 11 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "Test"
description: "Run Tests"
runs:
using: "composite"
steps:
- name: Setup
uses: ./.github/actions/setup

- name: Run Tests
shell: bash
run: npm run test
42 changes: 42 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI/CD Pipeline

on:
pull_request:
push:
branches:
- main
- dev

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Run Checks
uses: ./.github/actions/check

test:
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Run Tests
uses: ./.github/actions/test

deploy:
runs-on: ubuntu-latest
needs:
- check
- test
steps:
- name: Check Out Code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Deploy App
uses: ./.github/actions/deploy
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ To add a npm package `pkg` use the following command:

```shell
cd jeton
npm install pkg --workspace=<YOUR PROJECT/WORKSPACE>
npm install --workspace=<YOUR PROJECT/WORKSPACE> [--save|--save-dev] pkg
```

For example:

```shell
cd jeton
npm install --workspace=apps/web --save-dev @cloudflare/next-on-pages
```

### Lint Project
Expand Down
2 changes: 2 additions & 0 deletions apps/web/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Button } from "@jeton/ui/button";
import Image from "next/image";
import styles from "./page.module.css";

export const runtime = "edge";

export default function Home() {
return (
<div className={styles.page}>
Expand Down
6 changes: 6 additions & 0 deletions apps/web/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { setupDevPlatform } from "@cloudflare/next-on-pages/next-dev";

/** @type {import('next').NextConfig} */
const nextConfig = {};

if (process.env.NODE_ENV === "development") {
await setupDevPlatform();
}

export default nextConfig;
12 changes: 7 additions & 5 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@
"scripts": {
"dev": "next dev --turbo",
"build": "next build",
"start": "next start"
"start": "next start",
"next-on-pages:build": "npx @cloudflare/next-on-pages"
},
"dependencies": {
"@jeton/ui": "*",
"next": "15.0.0-rc.0",
"react": "19.0.0-rc-f994737d14-20240522",
"react-dom": "19.0.0-rc-f994737d14-20240522",
"next": "15.0.0-rc.0"
"react-dom": "19.0.0-rc-f994737d14-20240522"
},
"devDependencies": {
"@cloudflare/next-on-pages": "^1.13.2",
"@jeton/typescript-config": "*",
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18"
"@types/react-dom": "^18",
"typescript": "^5"
}
}
11 changes: 11 additions & 0 deletions apps/web/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"tasks": {
"build": {
"dependsOn": ["next-on-pages:build"],
"outputs": [".vercel/**"]
},
"next-on-pages:build": {}
}
}
Loading

0 comments on commit d9a6ea4

Please sign in to comment.