Skip to content

Commit

Permalink
feat: script CD
Browse files Browse the repository at this point in the history
  • Loading branch information
ramamimu committed Feb 16, 2024
1 parent 056273c commit 7e2b3c4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ jobs:
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PK_VM }}
port: ${{ secrets.SSH_PORT }}
script: whoami
script: |
pm2 list
rm -rf thread-api
git clone https://github.com/ramamimu/thread-api.git thread-api
cp /home/ahm_f_ramadhani/.env thread-api/.env
cd thread-api
npm install --omit=dev
pm2 restart src/app.js --name node-service
4 changes: 4 additions & 0 deletions src/Infrastructures/http/createServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const users = require("../../Interfaces/http/api/users");
const authentications = require("../../Interfaces/http/api/authentications");
const threads = require("../../Interfaces/http/api/threads");
const comments = require("../../Interfaces/http/api/comments");
const ping = require("../../Interfaces/http/api/ping");

const createServer = async (container) => {
const server = Hapi.server({
Expand Down Expand Up @@ -54,6 +55,9 @@ const createServer = async (container) => {
plugin: comments,
options: { container },
},
{
plugin: ping,
},
]);

server.ext("onPreResponse", (request, h) => {
Expand Down
21 changes: 21 additions & 0 deletions src/Interfaces/http/api/ping/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* istanbul ignore file */

module.exports = {
name: "ping",
register: async (server) => {
server.route([
{
method: "GET",
path: "/ping",
handler: (request, h) => {
return h
.response({
status: "success",
message: "pong",
})
.code(200);
},
},
]);
},
};

0 comments on commit 7e2b3c4

Please sign in to comment.