From e9e580b74d3c74aacb6f9453a7675b74af828f43 Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Tue, 7 Jan 2020 23:03:26 +0100 Subject: [PATCH] Adding CI and making CI ready --- .drone.status | 3 +++ .drone.yml | 20 ++++++++++++++++++++ Dockerfile | 20 ++++++++++++++++++++ package-lock.json | 41 ++++++++++++++++++++++++++++++----------- package.json | 2 +- src/index.ts | 8 +++++++- 6 files changed, 81 insertions(+), 13 deletions(-) create mode 100644 .drone.status create mode 100644 .drone.yml create mode 100644 Dockerfile diff --git a/.drone.status b/.drone.status new file mode 100644 index 0000000..e208f56 --- /dev/null +++ b/.drone.status @@ -0,0 +1,3 @@ +{ + "url": "https://drone.hibas123.de/hibas123/THM_OSPLUS_NEWS_MAILER" +} \ No newline at end of file diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..06a8b5f --- /dev/null +++ b/.drone.yml @@ -0,0 +1,20 @@ +kind: pipeline +type: docker +name: default + +steps: + - name: Build with node + image: node:12 + commands: + - npm install + - npm run build + - name: Publish to docker + image: plugins/docker + settings: + username: + from_secret: docker_username + password: + from_secret: docker_password + auto_tag: true + repo: hibas123.azurecr.io/telegram-rss + registry: hibas123.azurecr.io diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7725137 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM node:12 + +LABEL maintainer="Fabian Stamm " + +RUN apt-get update + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +ENV NODE_ENV=production + +COPY ["package.json", "package-lock.json", "/usr/src/app/"] + +RUN npm install + +COPY lib/ /usr/src/app/lib + +VOLUME [ "/usr/src/app/logs", "/usr/src/app/persist"] + +CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 079e38e..d289145 100644 --- a/package-lock.json +++ b/package-lock.json @@ -865,7 +865,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -886,12 +887,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -906,17 +909,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -1033,7 +1039,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -1045,6 +1052,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -1059,6 +1067,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -1066,12 +1075,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -1090,6 +1101,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -1170,7 +1182,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -1182,6 +1195,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -1267,7 +1281,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -1303,6 +1318,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -1322,6 +1338,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -1365,12 +1382,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, diff --git a/package.json b/package.json index ba161d3..aeaf70c 100644 --- a/package.json +++ b/package.json @@ -32,4 +32,4 @@ "ssl-root-cas": "^1.2.5", "telegraf": "^3.24.1" } -} \ No newline at end of file +} diff --git a/src/index.ts b/src/index.ts index c5daaa2..6bff531 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,11 +12,17 @@ import fetch from "node-fetch"; import rss from "rss-parser"; import Telegraf from "telegraf"; +import * as fs from "fs"; + dotenv.config(); const parser = new rss(); const entities = new AllHtmlEntities(); -const adapter = new FileSync<{ feeds: IDBFeed[] }>("db.json"); +if (!fs.existsSync("./persist")) { + fs.mkdirSync("./persist") +} + +const adapter = new FileSync<{ feeds: IDBFeed[] }>("persist/db.json"); const db = low(adapter); db.defaults({ feeds: [] }).write();