diff --git a/.github/workflows/Backend-CD.yml b/.github/workflows/Backend-CD.yml new file mode 100644 index 0000000..ebfb7d9 --- /dev/null +++ b/.github/workflows/Backend-CD.yml @@ -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 diff --git a/.github/workflows/Backend-CI.yml b/.github/workflows/Backend-CI.yml new file mode 100644 index 0000000..2fd3b08 --- /dev/null +++ b/.github/workflows/Backend-CI.yml @@ -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 diff --git a/Backend/package.json b/Backend/package.json index ab36699..651eb75 100644 --- a/Backend/package.json +++ b/Backend/package.json @@ -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": "",