Skip to content

Commit

Permalink
Merge pull request #26 from moonstar-x/rework
Browse files Browse the repository at this point in the history
Complete Remake [TypeScript, Postgres, Crawler]
  • Loading branch information
moonstar-x authored Aug 12, 2024
2 parents 90e4a73 + 824ae00 commit 8ebdf03
Show file tree
Hide file tree
Showing 154 changed files with 13,040 additions and 17,244 deletions.
46 changes: 11 additions & 35 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,35 +1,11 @@
# OS Generated
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Thrashes
ehthumbs.db
Thumbs.db

# IDE
.vscode/
.idea/

# Node
node_modules
npm-debug.log

# Development
config/settings.json
data
dev-data

# Tests
__mocks__
test

# Git
.github
.git

# Root files
.eslintignore
.eslintrc
.gitignore
jest.config.js
# Ignore everything by default.
*

# Allow the public project files.
!migrations
!src
!Dockerfile
!LICENSE
!package*.json
!README.md
!tsconfig*.json
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
node_modules
build
12 changes: 7 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"globals": {
"NodeJS": true
},
"extends": [
"greencoast/node"
"@moonstar-x/eslint-config/rules/node",
"@moonstar-x/eslint-config/rules/typescript"
],
"rules": {
"one-var": "off"
},
"parserOptions": {
"ecmaVersion": 2020
"no-dupe-class-members": "off",
"camelcase": "off"
}
}
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Make sure that your PR fulfills these requirements:
- [ ] Tests have been added for this feature.
- [ ] All tests pass on your local machine.
- [ ] Code has been linted with the proper rules.
- [ ] Project builds on your local machine.

### :page_facing_up: Description

Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/callable-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Build Docker Image

on:
workflow_call:
inputs:
ghcr_image_name:
required: true
type: string
image_name:
required: true
type: string
image_tag:
required: true
type: string
ghcr_username:
rquired: true
type: string
dockerhub_username:
required: true
type: string
secrets:
ghcr_token:
required: true
dockerhub_token:
required: true

jobs:
build:
name: Build Docker Image
runs-on: ubuntu-latest

steps:
- name: Checkout the Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Cache Docker Layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ inputs.ghcr_username }}
password: ${{ secrets.ghcr_token }}

- name: Login to DockerHub Registry
uses: docker/login-action@v3
with:
username: ${{ inputs.dockerhub_username }}
password: ${{ secrets.dockerhub_token }}

- name: Get Version from package.json
id: package-version
uses: martinbeentjes/npm-get-version-action@master

- name: Build & Push Docker Image
id: docker_build
uses: docker/build-push-action@v3
env:
GHCR_IMAGE: ghcr.io/${{ inputs.ghcr_image_name }}
DOCKERHUB_IMAGE: ${{ inputs.dockerhub_username }}/${{ inputs.image_name }}
with:
context: .
push: true
tags: |
${{ env.GHCR_IMAGE }}:${{ inputs.image_tag }}
${{ env.GHCR_IMAGE }}:${{ steps.package-version.outputs.current-version }}
${{ env.DOCKERHUB_IMAGE }}:${{ inputs.image_tag }}
${{ env.DOCKERHUB_IMAGE }}:${{ steps.package-version.outputs.current-version }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm64/v8

- name: Image Digest
run: echo ${{ steps.docker_build.outputs.digest }}
35 changes: 35 additions & 0 deletions .github/workflows/callable-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Run Tests

on:
workflow_call:

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest

steps:
- name: Checkout the Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install Dependencies
run: npm ci

- name: Run Type Checks
run: npm run type-check

- name: Run Linter
run: npm run lint

- name: Run Tests
run: npm run test
env:
TZ: America/Guayaquil
44 changes: 0 additions & 44 deletions .github/workflows/ci.yml

This file was deleted.

55 changes: 0 additions & 55 deletions .github/workflows/docker-build.yml

This file was deleted.

14 changes: 14 additions & 0 deletions .github/workflows/on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: On Pull Request

on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened

jobs:
test:
name: Run Tests
uses: ./.github/workflows/callable-test.yml
26 changes: 26 additions & 0 deletions .github/workflows/on-push-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: On Push (Main)

on:
push:
branches:
- main

jobs:
test:
name: Run Tests
uses: ./.github/workflows/callable-test.yml

build:
name: Build Docker Image
uses: ./.github/workflows/callable-build.yml
needs:
- test
with:
ghcr_image_name: ${{ github.repository }}
image_name: discord-free-games-notifier
image_tag: latest
ghcr_username: ${{ github.actor }}
dockerhub_username: moonstarx
secrets:
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
Loading

0 comments on commit 8ebdf03

Please sign in to comment.