Skip to content

added github workflow and improvement #6

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

Open
wants to merge 7 commits into
base: main
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
43 changes: 43 additions & 0 deletions .github/workflows/deploy_api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Docker push Api

on:
push:
branches: [main]
workflow_dispatch:

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

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push api
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.api
push: true
tags: 100xdevs/dpin-uptime-api:${{ github.sha}}

- name: Deploy to api ec2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.API_EC2_IP }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
#login to Docker Hub in case of private repo
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_TOKEN }}
#stop and remove existing api container
docker stop betteruptime-api || true
docker rm betteruptime-api || true
docker pull 100xdevs.com/dpin-uptime-api:${{ github.sha }}
docker run -d --name betteruptime-api -p 3000:3000 100xdevs/dpin-uptime-api:${{ github.sha }}
46 changes: 46 additions & 0 deletions .github/workflows/deploy_frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: Continuous Deployment web
on:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/Dockerfile.frontend
push: true
tags: 100xdevs/dpin-uptime-frontend:${{ github.sha }}
build-args: |
DATABASE_URL=${{ secrets.DATABASE_URL }}

- name: Deploy to Frontend ec2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.FRONTEND_EC2_IP }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
#login to Docker Hub in case of private repo
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_TOKEN }}
#stop and remove existing frontend container
docker stop betteruptime-frontend || true
docker rm betteruptime-frontend || true
docker pull 100xdevs.com/dpin-uptime-frontend:${{ github.sha }}
docker run -d --name betteruptime-frontend -p 3000:3000 100xdevs/dpin-uptime-frontend:${{ github.sha }}

39 changes: 39 additions & 0 deletions .github/workflows/deploy_hub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Docker push Hub
on:
push:
branches: [main]

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Hub
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.hub
push: true
tags: 100xdevs/dpin-uptime-hub:${{ github.sha}}

- name: Deploy to Frontend ec2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HUB_EC2_IP }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
#login to Docker Hub in case of private repo
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_TOKEN }}
#stop and remove existing hub container
docker stop betteruptime-hub || true
docker rm betteruptime-hub || true
docker pull 100xdevs.com/dpin-uptime-hub:${{ github.sha }}
docker run -d --name betteruptime-hub -p 3000:3000 100xdevs/dpin-uptime-hub:${{ github.sha }}
31 changes: 31 additions & 0 deletions .github/workflows/deploy_validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Docker push Validator

on:
push:
branches: [main]


jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Validator
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.validator
push: true
tags: 100xdevs/dpin-uptime-validator:${{ github.sha}}


#no need to push to ec2 as every validator will run accouring to them
# we will just publish docker imageUrl
1 change: 1 addition & 0 deletions apps/api/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TREASURY_WALLET=
21 changes: 11 additions & 10 deletions apps/api/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

export const JWT_PUBLIC_KEY = process.env.JWT_PUBLIC_KEY || `-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxYRjjCo+ZhdDrsVduRaj
o4U9XNYbUxG4LBgtrHUpvMrRda6yXXfuecC0zwdF4O16ZNp9LMyy2bllXG8HOWyw
ac/r/9Zt98A9jMUEKq/AhRvaRaavr9jMFceJNTebFMOnzPRZGIhMWWOGPsrwqWLa
JbMtnAd2IlQc4MNJmns2NeaPmujDysZDmN5BwLd0LzTaktOFsrVCFYu7MiL7sYi9
229OovGxu55Y1qpekwt42nuipbpZEx59FdAIpJCgjsp8GeqavC5ySWuhRbKGTO+e
qiBV0S9m134FuGRc67HEYcr7BkTSFwF4pD/L2culHEBaRedilGdRbNAGFAQhN4mS
yQIDAQAB
export const JWT_PUBLIC_KEY =
process.env.JWT_PUBLIC_KEY ||
`-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqhRzktxm2Z/vQlmwl4Md
JpOoXSeT9RQWbE+XHRHp2UGaRVHhuZg5Tu2trXmn40R7BfZlWUuIgaKyqwYw1UkX
pCYrpfX8vqwIELY33hm6Ssxt/nI6fXcyM6F/w0c/tCNxbSQj+dn5R0Oa3nY/zJc1
RopATCkB2ZPT1obOERyEMNjnfrxcmIlK0tmOLsvkYXAjfDYNH29JrD/DGY7m0/Am
VHWaJM/lIkL+Lwq++mmO2cWD3ya4WxUgKtIDUw9PX5WOUiDigC5OK/Px04glFIyS
VG3I4BtsRt0s+G61DQjYZgrUHudJj7zVCGGHayMUrMCl37LWk1ply7RGrZlL78/M
MQIDAQAB
-----END PUBLIC KEY-----
`;
`;
Loading