Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend CI / CD workflows #29

Merged
merged 6 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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