Skip to content

Commit

Permalink
re-unite
Browse files Browse the repository at this point in the history
- api-gateway
- scheduler
- worker
- taskmanager
  • Loading branch information
tuana9a committed Apr 15, 2024
1 parent 91c106c commit f58a286
Show file tree
Hide file tree
Showing 387 changed files with 75,449 additions and 200 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/build-and-push-api-gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build-and-push-api-gateway

env:
DOCKER_HUB_USERNAME: tuana9a
IMAGE_NAME: tuana9a/dkhptd-api-gateway

on:
push:
branches:
- "main"
paths:
- "api-gateway/**"

jobs:
build-and-push:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

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

- name: Set docker tags
run: |
echo DOCKER_TAG_MONTHLY=$(date +"%Y.%m") >> $GITHUB_ENV
echo DOCKER_TAG_DAILY=$(date +"%Y.%m.%d") >> $GITHUB_ENV
echo DOCKER_TAG_SECONDLY=$(date +"%Y.%m.%d.%H%M%S") >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./api-gateway
file: ./api-gateway/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_SECONDLY }}
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_DAILY }}
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_MONTHLY }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Send notification
if: always()
shell: bash
run: |
curl -X POST https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage \
-H "Content-Type: application/json" \
-d "{
\"chat_id\":\"${{ secrets.TELEGRAM_CHAT_ID }}\",
\"disable_notification\":true,
\"text\":\"${{ job.status }} ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\\nimg: ${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_SECONDLY }}\"
}"
60 changes: 60 additions & 0 deletions .github/workflows/build-and-push-scheduler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build-and-push-scheduler

env:
DOCKER_HUB_USERNAME: tuana9a
IMAGE_NAME: tuana9a/dkhptd-scheduler

on:
push:
branches:
- "main"
paths:
- "scheduler/**"

jobs:
build-and-push:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

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

- name: Set docker tags
run: |
echo DOCKER_TAG_MONTHLY=$(date +"%Y.%m") >> $GITHUB_ENV
echo DOCKER_TAG_DAILY=$(date +"%Y.%m.%d") >> $GITHUB_ENV
echo DOCKER_TAG_SECONDLY=$(date +"%Y.%m.%d.%H%M%S") >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./scheduler
file: ./scheduler/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_SECONDLY }}
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_DAILY }}
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_MONTHLY }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Send notification
if: always()
shell: bash
run: |
curl -X POST https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage \
-H "Content-Type: application/json" \
-d "{
\"chat_id\":\"${{ secrets.TELEGRAM_CHAT_ID }}\",
\"disable_notification\":true,
\"text\":\"${{ job.status }} ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\\nimg: ${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_SECONDLY }}\"
}"
60 changes: 60 additions & 0 deletions .github/workflows/build-and-push-taskmanager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build-and-push-taskmanager

env:
DOCKER_HUB_USERNAME: tuana9a
IMAGE_NAME: tuana9a/dkhptd-taskmanager

on:
push:
branches:
- "main"
paths:
- "taskmanager/**"

jobs:
build-and-push:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

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

- name: Set docker tags
run: |
echo DOCKER_TAG_MONTHLY=$(date +"%Y.%m") >> $GITHUB_ENV
echo DOCKER_TAG_DAILY=$(date +"%Y.%m.%d") >> $GITHUB_ENV
echo DOCKER_TAG_SECONDLY=$(date +"%Y.%m.%d.%H%M%S") >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./taskmanager
file: ./taskmanager/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_SECONDLY }}
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_DAILY }}
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_MONTHLY }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Send notification
if: always()
shell: bash
run: |
curl -X POST https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage \
-H "Content-Type: application/json" \
-d "{
\"chat_id\":\"${{ secrets.TELEGRAM_CHAT_ID }}\",
\"disable_notification\":true,
\"text\":\"${{ job.status }} ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\\nimg: ${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_SECONDLY }}\"
}"
60 changes: 60 additions & 0 deletions .github/workflows/build-and-push-thoi-khoa-bieu-parser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build-and-push-thoi-khoa-bieu-parser

env:
DOCKER_HUB_USERNAME: tuana9a
IMAGE_NAME: tuana9a/dkhptd-thoi-khoa-bieu-parser

on:
push:
branches:
- "main"
paths:
- "thoi-khoa-bieu-parser/**"

jobs:
build-and-push:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

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

- name: Set docker tags
run: |
echo DOCKER_TAG_MONTHLY=$(date +"%Y.%m") >> $GITHUB_ENV
echo DOCKER_TAG_DAILY=$(date +"%Y.%m.%d") >> $GITHUB_ENV
echo DOCKER_TAG_SECONDLY=$(date +"%Y.%m.%d.%H%M%S") >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./thoi-khoa-bieu-parser
file: ./thoi-khoa-bieu-parser/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_SECONDLY }}
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_DAILY }}
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_MONTHLY }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Send notification
if: always()
shell: bash
run: |
curl -X POST https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage \
-H "Content-Type: application/json" \
-d "{
\"chat_id\":\"${{ secrets.TELEGRAM_CHAT_ID }}\",
\"disable_notification\":true,
\"text\":\"${{ job.status }} ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\\nimg: ${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_SECONDLY }}\"
}"
51 changes: 51 additions & 0 deletions .github/workflows/build-and-push-web.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: build-and-push-web

on:
push:
branches:
- "main"
paths:
- "web/**"

jobs:
build-and-push:
runs-on: ubuntu-20.04
permissions:
contents: read
deployments: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Build
working-directory: ./web
shell: bash
run: |
npm i
npm run build
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: dkhptd-web
directory: ./web/dist/dkhptd-web/
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

- name: Send notification
if: always()
shell: bash
run: |
curl -X POST https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage \
-H "Content-Type: application/json" \
-d "{
\"chat_id\":\"${{ secrets.TELEGRAM_CHAT_ID }}\",
\"disable_notification\":true,
\"text\":\"${{ job.status }} ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\"
}"
60 changes: 60 additions & 0 deletions .github/workflows/build-and-push-worker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build-and-push-worker

env:
DOCKER_HUB_USERNAME: tuana9a
IMAGE_NAME: tuana9a/dkhptd-worker

on:
push:
branches:
- "main"
paths:
- "worker/**"

jobs:
build-and-push:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

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

- name: Set docker tags
run: |
echo DOCKER_TAG_MONTHLY=$(date +"%Y.%m") >> $GITHUB_ENV
echo DOCKER_TAG_DAILY=$(date +"%Y.%m.%d") >> $GITHUB_ENV
echo DOCKER_TAG_SECONDLY=$(date +"%Y.%m.%d.%H%M%S") >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./worker
file: ./worker/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_SECONDLY }}
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_DAILY }}
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_MONTHLY }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Send notification
if: always()
shell: bash
run: |
curl -X POST https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage \
-H "Content-Type: application/json" \
-d "{
\"chat_id\":\"${{ secrets.TELEGRAM_CHAT_ID }}\",
\"disable_notification\":true,
\"text\":\"${{ job.status }} ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\\nimg: ${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_SECONDLY }}\"
}"
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ mặc dù tên project là đăng ký học phần tự động tuy nhiên proje

project được triển khai dưới dạng nhiều module, được triển khai độc lập

- [dkhptd-api-gateway](https://github.com/tuana9a/dkhptd-api-gateway): api server xử lý các request từ trình duyệt
- [dkhptd-scheduler](https://github.com/tuana9a/dkhptd-scheduler): bộ hẹn giờ liên tục kiểm tra xem đã tới thời điểm hẹn giờ của sinh viên hay chưa, nếu đã đến giờ sẽ gửi yêu cầu này cho worker thông qua message queue
- [dkhptd-worker](https://github.com/tuana9a/dkhptd-worker): thực thi các yêu cầu đăng ký tự động, sau khi xử lý xong sẽ gửi kết quả vào message queue cho taskamager xử lý
- [dkhptd-taskmanager](https://github.com/tuana9a/dkhptd-taskmanager): xử lý kết quả mà worker trả về để có các logic xử lý như tự động thử đăng ký lại
- [hust-tkb-xlsx-parser](https://github.com/tuana9a/hust-tkb-xlsx-parser) ( _optional_ ): xử lý file excel thời khóa biểu dự kiến của nhà trường để trích xuất thông tin
- `web`: web frontend
- `api-gateway`: api server xử lý các request từ trình duyệt
- `scheduler`: bộ hẹn giờ liên tục kiểm tra xem đã tới thời điểm hẹn giờ của sinh viên hay chưa, nếu đã đến giờ sẽ gửi yêu cầu này cho worker thông qua message queue
- `worker`: thực thi các yêu cầu đăng ký tự động, sau khi xử lý xong sẽ gửi kết quả vào message queue cho taskamager xử lý
- `taskmanager`: xử lý kết quả mà worker trả về để có các logic xử lý như tự động thử đăng ký lại
- (~**optional**) `thoi-khoa-bieu-parser`: xử lý file excel thời khóa biểu dự kiến của nhà trường để trích xuất thông tin

các module trên sẽ truy cập, trao đổi thông tin thông qua database là [MongoDB](https://www.mongodb.com/docs/v5.0/tutorial/getting-started/) và message queue là [RabbitMQ](https://www.rabbitmq.com/getstarted.html)

Expand Down
3 changes: 3 additions & 0 deletions api-gateway/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.js
dist
node_modules
Loading

0 comments on commit f58a286

Please sign in to comment.