Skip to content

Commit

Permalink
Merge pull request #29 from omar-sarfraz/backend/workflows
Browse files Browse the repository at this point in the history
Backend CI / CD workflows
  • Loading branch information
omar-sarfraz authored Sep 25, 2024
2 parents 8ceb018 + 563f59d commit 43fba9f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/Backend-CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Backend CD

on:
workflow_run:
workflows: ["Backend CI"]
types:
- completed

jobs:
build:
runs-on: self-hosted

steps:
- uses: actions/checkout@v4

- name: Pull Docker image
run: sudo docker compose pull

- name: Start Containers
env:
ENVIRONMENT: ${{ secrets.ENVIRONMENT }}
DB_NAME: ${{ secrets.DB_NAME}}
DB_USER: ${{ secrets.DB_USER}}
DB_HOST: ${{ secrets.DB_HOST}}
DB_PORT: ${{ secrets.DB_PORT}}
DB_PASSWORD: ${{ secrets.DB_PASSWORD}}
PORT: ${{ secrets.PORT}}
KEY: ${{ secrets.KEY}}
SECTRET: ${{ secrets.SECTRET}}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY}}
run: sudo docker compose up --force-recreate
31 changes: 31 additions & 0 deletions .github/workflows/Backend-CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Backend CI

on:
push:
branches: ["main", "backend/workflows"]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Login Dockerhub
env:
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}}
run: docker login -u $DOCKER_USERNAME -p $DOCKER_TOKEN

- name: Build Docker images for backend and graphql
env:
ENVIRONMENT: ${{ secrets.ENVIRONMENT }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: |
docker compose build backend
docker compose build graphql
- name: Push Docker images to DockerHub
run: |
docker push omarsarfraz/project-listings:backend
docker push omarsarfraz/project-listings:graphql
3 changes: 2 additions & 1 deletion Backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"start": "node -r dotenv/config dist/index.js dotenv_config_path=.env.local",
"dev": "nodemon -r dotenv/config index.ts dotenv_config_path=.env.local",
"test": "echo \"Error: no test specified\" && exit 1",
"sentry:sourcemaps": "sentry-cli sourcemaps inject --org arbisoft-m1 --project project-listings-backend ./dist && sentry-cli sourcemaps upload --org arbisoft-m1 --project project-listings-backend ./dist"
"sentry:login": "sentry-cli login --auth-token $SENTRY_AUTH_TOKEN",
"sentry:sourcemaps": "npm run sentry:login && sentry-cli sourcemaps inject --org arbisoft-m1 --project project-listings-backend ./dist && sentry-cli sourcemaps upload --org arbisoft-m1 --project project-listings-backend ./dist"
},
"keywords": [],
"author": "",
Expand Down

0 comments on commit 43fba9f

Please sign in to comment.