9 Commits

6 changed files with 72 additions and 14 deletions

52
.github/workflows/deploy.yml vendored Normal file
View File

@@ -0,0 +1,52 @@
# This is a basic workflow to help you get started with Actions
name: Deploy
# Controls when the workflow will run
on:
push:
tags:
- '*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Setup SSH Agent
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add VPS to known_hosts
run: |
ssh-keyscan -p ${{ secrets.VPS_PORT }} -H ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts
- name: Deploy to VPS
run: |
ssh -p ${{ secrets.VPS_PORT }} ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} "
cd /home/${{ secrets.VPS_USER }}/protojx/protojx-manager &&
git pull &&
# Stop and remove old container if exists
docker stop protojx_manager 2>/dev/null || true &&
docker rm protojx_manager 2>/dev/null || true &&
# Build new image
docker buildx build -t protojx_manager . &&
# Run new container
docker run -d \
--name protojx_manager \
--restart unless-stopped \
--network shared \
protojx_manager
"

View File

@@ -7,4 +7,6 @@ COPY . .
RUN apt-get update && apt-get install -y iputils-ping
RUN npm i
# RUN npm run register
CMD [ "npm", "run", "start" ]

View File

@@ -12,7 +12,7 @@ A status bot and other features for protojx.
| Number of services down in the bot's status. | 🌐 |
| Notification system in case of downtime. | 🌐 |
| Ability to create persistent status messages that update automatically. (/live_status) | 🌐 |
| Deployment workflow on Oracle VPS. | |
| Deployment workflow on Oracle VPS. | 🌐 |
| Filter for notifs. | 🌐 |
- 🌐 -> In production

7
package-lock.json generated
View File

@@ -11,6 +11,7 @@
"dependencies": {
"@types/ping": "^0.4.4",
"cron": "^4.3.3",
"dayjs": "^1.11.19",
"discord.js": "^14.24.2",
"dotenv": "^17.2.2",
"pg": "^8.16.3",
@@ -552,9 +553,9 @@
}
},
"node_modules/dayjs": {
"version": "1.11.18",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.18.tgz",
"integrity": "sha512-zFBQ7WFRvVRhKcWoUh+ZA1g2HVgUbsZm9sbddh8EC5iv93sui8DVVz1Npvz+r6meo9VKfa8NyLWBsQK1VvIKPA==",
"version": "1.11.19",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz",
"integrity": "sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==",
"license": "MIT"
},
"node_modules/debug": {

View File

@@ -30,6 +30,7 @@
"dependencies": {
"@types/ping": "^0.4.4",
"cron": "^4.3.3",
"dayjs": "^1.11.19",
"discord.js": "^14.24.2",
"dotenv": "^17.2.2",
"pg": "^8.16.3",

View File

@@ -7,6 +7,7 @@ import { HostsLog } from "../entity/hostslog.entity";
import { Repository } from "typeorm";
import { Follow } from "../entity/follow.entity";
import { Guild } from "../entity/guild.entity";
import dayjs from "dayjs";
type Nofity = {time: Date, name : string, alive : boolean, type : InfraType, host: string};
@@ -14,16 +15,16 @@ export class StatusService {
public hosts: Host[] = [
{
'host': 'https://protojx.com',
'name': 'Protojx Website',
host: 'https://protojx.com',
name: 'Protojx Website',
alive: false,
ping_type: 'website',
type: 'website',
notify: false
},
{
'host': 'https://manager.protojx.com',
'name': 'Espace Client',
host: 'https://manager.protojx.com',
name: 'Espace Client',
alive: false,
ping_type: 'website',
type: 'website',
@@ -296,15 +297,16 @@ export class StatusService {
(text) =>
text.setContent('## ' + sectionData.title + '\n' + hostTexts.filter((v) => v.type == sectionData.type).map((v) => v.value).join('\n'))
)
.setThumbnailAccessory(
(acc) =>
acc.setURL(sectionData.thumbnail)
)
.setThumbnailAccessory(
(acc) =>
acc.setURL(sectionData.thumbnail)
)
)
});
const now = new Date();
container.addTextDisplayComponents((text) => text.setContent(`${live ? 'Last update : ' : ''}${now.getDate()}-${now.getMonth() + 1}-${now.getFullYear()} ${(now.getHours() + '').padStart(2, "0")}:${(now.getMinutes() + '').padStart(2, "0")} - Receive automatic notifications when there is an outage with /follow !`));
container.addSeparatorComponents((s) => s);
container.addTextDisplayComponents((text) => text.setContent(`:globe_with_meridians: Website Status : https://statut.protojx.com/\n${live ? 'Last update : ' : ''}<t:${dayjs().unix()}:f> - Receive automatic notifications when there is an outage with /follow !`));
return container;
}