Skip to content

Commit

Permalink
Add CI and fix frequency calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
thevops committed Jun 27, 2024
1 parent b65597b commit 379b68f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: Build and Push Docker Image

on:
push:
branches:
- "master"
tags:
- "v*"
pull_request:
branches:
- "master"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 🏧 Checkout Repository
uses: actions/checkout@v4

- name: 🛠️ Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: 📝 Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: thevops/youtube-tracker
tags: |
type=sha
type=semver,pattern={{raw}}
type=ref,event=branch
type=ref,event=pr
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: 📦 Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1.1.4-alpine as base
FROM oven/bun:1.1.4-alpine AS base

# install dependencies into temp directory
# this will cache them and speed up future builds
Expand All @@ -12,7 +12,7 @@ RUN cd /temp/prod && bun install --frozen-lockfile --production


# final image
FROM base as release
FROM base AS release

RUN apk add -q --progress --update --no-cache dumb-init

Expand Down
9 changes: 9 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ tasks:
desc: Start the app
cmds:
- bun run src/index.ts config/production.yaml
env:
NODE_ENV: production

run-script:
desc: Run a single script
cmds:
- bun {{.CLI_ARGS}}
env:
NODE_ENV: production

#
# Build
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ async function main() {
for (const feed of Config.feeds) {
logger.debug(`Checking feed: ${feed.name}`);

// Get current time minus the frequency (minutes) plus a buffer of 5 minutes
// Get current time and subtract the frequency time (plus 5 minutes more as a buffer) in minutes
const previous_check = new Date(
Date.now() - Config.frequency * 60000 + 5 * 60000,
Date.now() - (Config.frequency + 5) * 60000,
);
logger.debug(`Previous check: ${previous_check.toISOString()}`);

Expand Down

0 comments on commit 379b68f

Please sign in to comment.