Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
book000 committed Jul 9, 2022
0 parents commit 367a2e8
Show file tree
Hide file tree
Showing 44 changed files with 7,002 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: ci

on:
push:
pull_request:

jobs:
ci:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [16]
directory: [register, downloader]

steps:
- name: Checkout 🛎
uses: actions/checkout@v3

- name: Setup node env 🏗
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
check-latest: true

- name: Get yarn cache directory path 🛠
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Cache node_modules 📦
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies 👨🏻‍💻
working-directory: ${{ matrix.directory }}
run: yarn

- name: Run linter 👀
working-directory: ${{ matrix.directory }}
run: yarn lint

- name: Run compile 🏗️
working-directory: ${{ matrix.directory }}
run: yarn compile
19 changes: 19 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Docker Image CI

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
directory: [register, downloader]

steps:
- uses: actions/checkout@v3
- name: Build the Docker image (downloader)
working-directory: ${{ matrix.directory }}
run: docker build . --file Dockerfile --tag ${{ github.event.repository.name }}-${{ matrix.directory }}:$(date +%s)
51 changes: 51 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Docker Publish

on:
release:
types: [published]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
publish:
name: Push Docker image to Docker Hub (${{ matrix.directory }})
runs-on: ubuntu-latest

strategy:
matrix:
directory: [register, downloader]


steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.directory }}

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: ${{ matrix.directory }}
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
23 changes: 23 additions & 0 deletions .github/workflows/hado-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: hadolint

on:
push:
pull_request:

jobs:
ci:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [16]
directory: [register, downloader]

steps:
- name: Checkout 🛎
uses: actions/checkout@v3

- uses: hadolint/[email protected]
with:
dockerfile: ${{ matrix.directory }}/Dockerfile
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
dist/
data/
TimeshiftRegister_old/

config.json
searchWords.json
2 changes: 2 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignored:
- DL3018
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch",
"runtimeExecutable": "yarn",
"cwd": "${workspaceFolder}",
"runtimeArgs": ["dev"],
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.tabSize": 2
}
24 changes: 24 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.8'

services:
register:
build: ./register
volumes:
- type: bind
source: ./data
target: /data
- type: bind
source: ./config.json
target: /app/config.json
restart: always

downloader:
build: ./downloader
volumes:
- type: bind
source: ./data
target: /data
- type: bind
source: ./config.json
target: /app/config.json
restart: always
13 changes: 13 additions & 0 deletions docker-compose.downloader.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.8'

services:
downloader:
build: ./downloader
volumes:
- type: bind
source: ./data
target: /data
- type: bind
source: ./config.json
target: /app/config.json
restart: always
13 changes: 13 additions & 0 deletions docker-compose.register.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.8'

services:
register:
build: ./register
volumes:
- type: bind
source: ./data
target: /data
- type: bind
source: ./config.json
target: /app/config.json
restart: always
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.8'

services:
register:
image: ghcr.io/tomacheese/niconico-timeshift-register:v1.0.0
volumes:
- type: bind
source: ./data
target: /data
- type: bind
source: ./config.json
target: /app/config.json
restart: always

downloader:
image: ghcr.io/tomacheese/niconico-timeshift-downloader:v1.0.0
volumes:
- type: bind
source: ./data
target: /data
- type: bind
source: ./config.json
target: /app/config.json
restart: always
3 changes: 3 additions & 0 deletions downloader/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
webpack.config.js
dist
node_modules
15 changes: 15 additions & 0 deletions downloader/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
env:
es2021: true
node: true
extends:
- standard
- plugin:@typescript-eslint/recommended
- prettier
parser: '@typescript-eslint/parser'
parserOptions:
ecmaVersion: latest
sourceType: module
project: ./tsconfig.json
plugins:
- '@typescript-eslint'
rules: {}
2 changes: 2 additions & 0 deletions downloader/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
semi: false
singleQuote: true
35 changes: 35 additions & 0 deletions downloader/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM golang:alpine as livedl-builder

RUN apk update && \
apk upgrade && \
apk add --no-cache git gcc musl-dev

RUN git clone https://github.com/nnn-revo2012/livedl.git /work/livedl

WORKDIR /work/livedl/src
RUN go build -o /work/livedl/livedl livedl.go

# /work/livedl

FROM node:18-alpine

RUN apk update && \
apk upgrade

COPY --from=livedl-builder /work/livedl/livedl /bin/livedl
RUN chmod +x /bin/livedl

WORKDIR /app

COPY package.json .
COPY yarn.lock .
RUN yarn install && \
yarn cache clean

COPY entrypoint.sh .
RUN chmod +x entrypoint.sh

COPY src src
COPY tsconfig.json .

ENTRYPOINT [ "/app/entrypoint.sh" ]
9 changes: 9 additions & 0 deletions downloader/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

while :
do
yarn build || true

# wait 6 hours
sleep 21600
done
44 changes: 44 additions & 0 deletions downloader/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "niconico-timeshift-register",
"version": "1.0.0",
"description": "",
"main": "dist/main.js",
"repository": "[email protected]:tomacheese/niconico-timeshift.git",
"author": "Tomachi",
"license": "MIT",
"private": true,
"scripts": {
"build": "ts-node -r tsconfig-paths/register ./src/main.ts",
"dev": "ts-node-dev -r tsconfig-paths/register ./src/main.ts",
"start": "node ./dist/main.js",
"compile": "tsc -p .",
"compile:test": "tsc -p . --noEmit",
"lint": "run-p -c lint:prettier lint:eslint lint:tsc",
"lint:prettier": "prettier --check src",
"lint:eslint": "eslint . --ext ts,tsx",
"lint:tsc": "tsc",
"fix": "run-s fix:prettier fix:eslint",
"fix:eslint": "eslint . --ext ts,tsx --fix",
"fix:prettier": "prettier --write src"
},
"devDependencies": {
"@types/cheerio": "0.22.31",
"@types/node": "18.0.3",
"@typescript-eslint/eslint-plugin": "5.30.5",
"@typescript-eslint/parser": "5.30.5",
"axios": "0.27.2",
"cheerio": "1.0.0-rc.12",
"eslint": "8.19.0",
"eslint-config-prettier": "8.5.0",
"eslint-config-standard": "17.0.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-n": "15.2.4",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "6.0.0",
"prettier": "2.7.1",
"ts-node": "10.8.2",
"ts-node-dev": "2.0.0",
"typescript": "4.7.4",
"yarn-run-all": "3.1.1"
}
}
Loading

0 comments on commit 367a2e8

Please sign in to comment.