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 4842700
Show file tree
Hide file tree
Showing 13 changed files with 6,833 additions and 1,244 deletions.
10 changes: 10 additions & 0 deletions .github/actions/check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Check"
description: "Run Checks"
runs:
using: "composite"
steps:
- name: Setup
uses: ./.github/actions/setup
- name: Run Checks
shell: bash
run: npm run check
19 changes: 19 additions & 0 deletions .github/actions/deploy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Deploy"
description: "Deploy Apps"
inputs:
cloudflare_api_token:
description: "the couldflare api token"
required: true
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: ${{ inputs.cloudflare_api_token }}
workingDirectory: "apps/web"
20 changes: 20 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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
10 changes: 10 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Test"
description: "Run Tests"
runs:
using: "composite"
steps:
- name: Setup
uses: ./.github/actions/setup
- name: Run Tests
shell: bash
run: npm run test
49 changes: 49 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI/CD Pipeline

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

permissions:
id-token: write
contents: read
deployments: write

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
with:
cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
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;
13 changes: 8 additions & 5 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
"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",
"@cloudflare/workers-types": "^4.20240806.0",
"@jeton/typescript-config": "*",
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18"
"@types/react-dom": "^18",
"typescript": "^5"
}
}
3 changes: 2 additions & 1 deletion apps/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": ["node_modules"]
"exclude": ["node_modules"],
"types": ["@cloudflare/workers-types/2024-07-29"]
}
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": {}
}
}
4 changes: 4 additions & 0 deletions apps/web/wrangler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = "jeton"
compatibility_date = "2024-07-29"
compatibility_flags = ["nodejs_compat"]
pages_build_output_dir = ".vercel/output/static"
Loading

0 comments on commit 4842700

Please sign in to comment.