Compare commits

...

4 Commits

Author SHA1 Message Date
Fabian Stamm
2e39587d3c Add gitea actions 2023-07-13 15:08:34 +02:00
edb3f22044 Switching to Earthfile 2023-06-07 21:11:05 +02:00
Fabian Stamm
791b601dec Increase delay between checks to 15 minutes
All checks were successful
continuous-integration/drone/tag Build is passing
continuous-integration/drone/push Build is passing
2023-04-26 20:03:27 +02:00
Fabian Stamm
1082dd7a71 Fix bug
All checks were successful
continuous-integration/drone/tag Build is passing
2023-04-26 19:58:59 +02:00
5 changed files with 61 additions and 37 deletions

36
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,36 @@
# .github/workflows/ci.yml
name: CI
on:
push:
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
env:
MY_DOCKER_USERNAME: ${{ secrets.MY_DOCKER_USERNAME }}
MY_DOCKER_PASSWORD: ${{ secrets.MY_DOCKER_PASSWORD }}
FORCE_COLOR: 1
steps:
- uses: https://github.com/earthly/actions-setup@v1
with:
version: v0.7.0
- uses: actions/checkout@v2
- name: Put back the git branch into git (Earthly uses it for tagging)
run: |
branch=""
if [ -n "$GITHUB_HEAD_REF" ]; then
branch="$GITHUB_HEAD_REF"
else
branch="${GITHUB_REF##*/}"
fi
git checkout -b "$branch" || true
- name: Docker Login
run: docker login git.hibas.dev --username "$MY_DOCKER_USERNAME" --password "$MY_DOCKER_PASSWORD"
- name: Earthly version
run: earthly --version
- name: Run build
run: earthly --push +docker-multi

View File

@ -1,32 +0,0 @@
FROM node:19 as builder
RUN mkdir -p /app
WORKDIR /app
COPY ["package.json", "yarn.lock", ".yarnrc.yml", "tsconfig.json", "/app/"]
COPY [".yarn", "/app/.yarn"]
COPY ["src", "/app/src"]
RUN yarn install
RUN yarn build
FROM node:19
LABEL maintainer="Fabian Stamm <dev@fabianstamm.de>"
RUN mkdir -p /app
WORKDIR /app
ENV NODE_ENV=production
COPY ["package.json", "yarn.lock", ".yarnrc.yml", "/app/"]
COPY [".yarn", "/app/.yarn"]
RUN yarn install
COPY --from=builder /app/lib/ /app/lib
VOLUME [ "/app/logs", "/app/persist"]
CMD ["node", "lib/index.js"]

19
Earthfile Normal file
View File

@ -0,0 +1,19 @@
VERSION 0.7
FROM node:lts-alpine3.18
WORKDIR /build
docker-multi:
BUILD --platform linux/amd64 --platform linux/arm64 +docker
docker:
COPY package.json yarn.lock .yarnrc.yml tsconfig.json .
COPY src ./src
COPY .yarn ./.yarn
RUN ls -l
RUN yarn install
RUN yarn build
WORKDIR /build
ENTRYPOINT ["node", "lib/index.js"]
ARG EARTHLY_TARGET_TAG
ARG TAG=$EARTHLY_TARGET_TAG
SAVE IMAGE --push git.hibas.dev/hibas123/telegram-rss:$TAG

View File

@ -1,6 +1,6 @@
{
"name": "rss-telegram-bot",
"version": "2.0.1",
"version": "2.0.3",
"main": "lib/index.js",
"author": "Fabian Stamm <dev@fabianstamm.de>",
"license": "MIT",

View File

@ -98,11 +98,12 @@ async function checkFeed(feed: Feed) {
// feed.addItems(newItems);
}
// const FEED_CHECK_INTERVAL = 1000 * 60 * 60;
const FEED_CHECK_INTERVAL = 1000 * 30;
const FEED_CHECK_INTERVAL = 1000 * 60 * 15;
// const FEED_CHECK_INTERVAL = 1000 * 30;
export default async function checkFeeds() {
while (true) {
Logging.info("Checking for feeds to synchronize");
let feed = await AppDataSource.manager.findOne(Feed, {
where: {
lastCheck: LessThan(new Date(Date.now() - FEED_CHECK_INTERVAL))
@ -113,14 +114,14 @@ export default async function checkFeeds() {
})
if (!feed) {
await new Promise(y => setTimeout(y, 1000));
await new Promise(y => setTimeout(y, 10000));
continue;
}
feed.lastCheck = new Date();
await AppDataSource.manager.save(feed);
Promise.resolve(async () => {
Promise.resolve().then(async () => {
await checkFeed(feed);
}).catch(err => {
Logging.warn("Error while checking feed: %s", feed.url);