Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added workflowxx #340

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name: Build on PR
name: Build succedds on PR

on:
pull_request:
branches:
- master
branches: -master

jobs:
build:
name: Build the project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
node-version: "20"

- name: Install Dependencies
run: npm install

- name: Generate prisma client
run: npm run db:generate

- name: Run Build
run: npm run build
59 changes: 31 additions & 28 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,43 @@ name: Build and Deploy to Docker Hub
on:
push:
branches:
- master
- master # Adjusted to trigger on pushes to master

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v2
- name: Check Out Repo
uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Prepare Dockerfile
run: cp ./docker/Dockerfile.user ./Dockerfile

- name: Build and Push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/Dockerfile.user
push: true
tags: 100xdevs/week-18-class:latest # Replace with your Docker Hub username and repository
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Verify Pushed Image
run: docker pull 100xdevs/week-18-class:latest # Replace with your Docker Hub username and repository
- name: Build and Push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: sparrow313dev/web-app:latest

- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
sudo docker pull 100xdevs/week-18-class:latest
sudo docker stop web-app || true
sudo docker rm web-app || true
sudo docker run -d --name web-app -p 3005:3000 100xdevs/week-18-class:latest
- name: Verify Pushed Image
run: docker pull sparrow313dev/web-app:latest

- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
sudo docker pull sparrow313dev/web-app:latest
sudo docker stop web-app || true
sudo docker rm web-app || true
sudo docker run -d --name web-app -p 3005:3000 sparrow313dev/web-app:latest
84 changes: 44 additions & 40 deletions apps/user-app/app/(dashboard)/transfer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,56 @@ import { getServerSession } from "next-auth";
import { authOptions } from "../../lib/auth";

async function getBalance() {
const session = await getServerSession(authOptions);
const balance = await prisma.balance.findFirst({
where: {
userId: Number(session?.user?.id)
}
});
return {
amount: balance?.amount || 0,
locked: balance?.locked || 0
}
const session = await getServerSession(authOptions);
const balance = await prisma.balance.findFirst({
where: {
userId: Number(session?.user?.id),
},
});
return {
amount: balance?.amount || 0,
locked: balance?.locked || 0,
};
}

async function getOnRampTransactions() {
const session = await getServerSession(authOptions);
const txns = await prisma.onRampTransaction.findMany({
where: {
userId: Number(session?.user?.id)
}
});
return txns.map(t => ({
time: t.startTime,
amount: t.amount,
status: t.status,
provider: t.provider
}))
const session = await getServerSession(authOptions);
const txns = await prisma.onRampTransaction.findMany({
where: {
userId: Number(session?.user?.id),
},
});
return txns.map(
(t: { startTime: any; amount: any; status: any; provider: any }) => ({
time: t.startTime,
amount: t.amount,
status: t.status,
provider: t.provider,
})
);
}

export default async function() {
const balance = await getBalance();
const transactions = await getOnRampTransactions();
export default async function () {
const balance = await getBalance();
const transactions = await getOnRampTransactions();

return <div className="w-screen">
hi
<div className="text-4xl text-[#6a51a6] pt-8 mb-8 font-bold">
Transfer
return (
<div className="w-screen">
hi
<div className="text-4xl text-[#6a51a6] pt-8 mb-8 font-bold">
Transfer
</div>
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 p-4">
<div>
<AddMoney />
</div>
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 p-4">
<div>
<AddMoney />
</div>
<div>
<BalanceCard amount={balance.amount} locked={balance.locked} />
<div className="pt-4">
<OnRampTransactions transactions={transactions} />
</div>
</div>
<div>
<BalanceCard amount={balance.amount} locked={balance.locked} />
<div className="pt-4">
<OnRampTransactions transactions={transactions} />
</div>
</div>
</div>
</div>
}
);
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
"dev": "turbo dev",
"lint": "turbo lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"db:generate": "cd packages/db && npx prisma generate && cd ../..",
"start-user-app": "cd ./apps/user-app && npm run start"

"start-user-app": "cd ./apps/user-app && npm run start",
"db:generate": "cd packages/db && npx prisma generate && cd ../../"
},
"devDependencies": {
"@repo/eslint-config": "*",
Expand Down