Skip to content

Commit

Permalink
feat: github actions - reset demo db daily, update dockerhub image on…
Browse files Browse the repository at this point in the history
… commit

* feat: github action - reset demo db on cron job

* feat: github action - update dockerhub image
  • Loading branch information
xdaybreakerx authored Feb 13, 2025
1 parent ab5a54e commit 4902c65
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Docker Image Pipeline

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Install dependencies
run: npm install

- name: Log in to DockerHub
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin

- name: Build Docker Image
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/aftermath-archive-backend:latest \
-t ${{ secrets.DOCKERHUB_USERNAME }}/aftermath-archive-backend:${{ github.sha }} .
- name: Push Docker Image to DockerHub
run: |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/aftermath-archive-backend:latest
docker push ${{ secrets.DOCKERHUB_USERNAME }}/aftermath-archive-backend:${{ github.sha }}
28 changes: 28 additions & 0 deletions .github/workflows/reset-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Reset MongoDB Demo Data

on:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight UTC
workflow_dispatch:

jobs:
reset-db:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Install dependencies
run: npm install

- name: Drop and Seed Database
run: npm run db:drop-and-seed
env:
MONGO_URI: ${{ secrets.DATABASE_URL }}

0 comments on commit 4902c65

Please sign in to comment.