Skip to content

Commit 39a9070

Browse files
author
Uros Marolt
authored
Enhancement/separate service for webhooks c 927 (#1409)
1 parent 3d7d355 commit 39a9070

File tree

77 files changed

+10743
-3426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+10743
-3426
lines changed

.github/workflows/lf-production-deploy-new.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
description: Deploy integration-sync-worker service?
1212
required: true
1313
type: boolean
14+
deploy_webhook_api:
15+
description: Deploy webhook-api service?
16+
required: true
17+
type: boolean
1418

1519
env:
1620
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
@@ -66,6 +70,27 @@ jobs:
6670
id: image
6771
run: echo "IMAGE=${{ steps.image-builder.outputs.image }}" >> $GITHUB_OUTPUT
6872

73+
build-and-push-webhook-api:
74+
runs-on: ubuntu-latest
75+
if: ${{ inputs.deploy_webhook_api }}
76+
outputs:
77+
image: ${{ steps.image.outputs.IMAGE }}
78+
defaults:
79+
run:
80+
shell: bash
81+
steps:
82+
- name: Check out repository code
83+
uses: actions/checkout@v2
84+
85+
- uses: ./.github/actions/build-docker-image
86+
id: image-builder
87+
with:
88+
image: webhook-api
89+
90+
- name: Set docker image output
91+
id: image
92+
run: echo "IMAGE=${{ steps.image-builder.outputs.image }}" >> $GITHUB_OUTPUT
93+
6994
deploy-search-sync-worker:
7095
needs: build-and-push-search-sync-worker
7196
runs-on: ubuntu-latest
@@ -101,3 +126,21 @@ jobs:
101126
service: integration-sync-worker
102127
image: ${{ needs.build-and-push-integration-sync-worker.outputs.image }}
103128
cluster: ${{ env.CROWD_CLUSTER }}
129+
130+
deploy-webhook-api:
131+
needs: build-and-push-webhook-api
132+
runs-on: ubuntu-latest
133+
if: ${{ inputs.deploy_webhook_api }}
134+
defaults:
135+
run:
136+
shell: bash
137+
138+
steps:
139+
- name: Check out repository code
140+
uses: actions/checkout@v2
141+
142+
- uses: ./.github/actions/deploy-service
143+
with:
144+
service: webhook-api
145+
image: ${{ needs.build-and-push-webhook-api.outputs.image }}
146+
cluster: ${{ env.CROWD_CLUSTER }}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: LF Staging Deploy Webhook API
2+
3+
on:
4+
push:
5+
branches:
6+
- 'lf-staging/**'
7+
- 'lf-staging-**'
8+
paths:
9+
- 'services/libs/**'
10+
- 'services/apps/webhook_api/**'
11+
12+
env:
13+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
14+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
15+
CROWD_CLUSTER: ${{ secrets.LF_STAGING_CLUSTER_NAME }}
16+
CROWD_ROLE_ARN: ${{ secrets.LF_STAGING_CLUSTER_ROLE_ARN }}
17+
AWS_ACCESS_KEY_ID: ${{ secrets.LF_AWS_ACCESS_KEY_ID }}
18+
AWS_SECRET_ACCESS_KEY: ${{ secrets.LF_AWS_SECRET_ACCESS_KEY }}
19+
AWS_REGION: ${{ secrets.LF_AWS_REGION }}
20+
SLACK_CHANNEL: deploys-lf-staging
21+
SLACK_WEBHOOK: ${{ secrets.LF_STAGING_SLACK_CHANNEL_HOOK }}
22+
23+
jobs:
24+
build-and-push:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
image: ${{ steps.image.outputs.IMAGE }}
28+
defaults:
29+
run:
30+
shell: bash
31+
32+
steps:
33+
- name: Check out repository code
34+
uses: actions/checkout@v2
35+
36+
- uses: ./.github/actions/build-docker-image
37+
id: image-builder
38+
with:
39+
image: webhook-api
40+
41+
- name: Set docker image output
42+
id: image
43+
run: echo "IMAGE=${{ steps.image-builder.outputs.image }}" >> $GITHUB_OUTPUT
44+
45+
deploy-webhook-api:
46+
needs: build-and-push
47+
runs-on: ubuntu-latest
48+
defaults:
49+
run:
50+
shell: bash
51+
52+
steps:
53+
- name: Check out repository code
54+
uses: actions/checkout@v2
55+
56+
- uses: ./.github/actions/deploy-service
57+
with:
58+
service: webhook-api
59+
image: ${{ needs.build-and-push.outputs.image }}
60+
cluster: ${{ env.CROWD_CLUSTER }}

.github/workflows/production-deploy-new.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
description: Deploy integration-sync-worker service?
1212
required: true
1313
type: boolean
14+
deploy_webhook_api:
15+
description: Deploy webhook-api service?
16+
required: true
17+
type: boolean
1418

1519
env:
1620
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
@@ -66,6 +70,27 @@ jobs:
6670
id: image
6771
run: echo "IMAGE=${{ steps.image-builder.outputs.image }}" >> $GITHUB_OUTPUT
6872

73+
build-and-push-webhook-api:
74+
runs-on: ubuntu-latest
75+
if: ${{ inputs.deploy_webhook_api }}
76+
outputs:
77+
image: ${{ steps.image.outputs.IMAGE }}
78+
defaults:
79+
run:
80+
shell: bash
81+
steps:
82+
- name: Check out repository code
83+
uses: actions/checkout@v2
84+
85+
- uses: ./.github/actions/build-docker-image
86+
id: image-builder
87+
with:
88+
image: webhook-api
89+
90+
- name: Set docker image output
91+
id: image
92+
run: echo "IMAGE=${{ steps.image-builder.outputs.image }}" >> $GITHUB_OUTPUT
93+
6994
deploy-search-sync-worker:
7095
needs: build-and-push-search-sync-worker
7196
runs-on: ubuntu-latest
@@ -101,3 +126,21 @@ jobs:
101126
service: integration-sync-worker
102127
image: ${{ needs.build-and-push-integration-sync-worker.outputs.image }}
103128
cluster: ${{ env.CROWD_CLUSTER }}
129+
130+
deploy-webhook-api:
131+
needs: build-and-push-webhook-api
132+
runs-on: ubuntu-latest
133+
if: ${{ inputs.deploy_webhook-api }}
134+
defaults:
135+
run:
136+
shell: bash
137+
138+
steps:
139+
- name: Check out repository code
140+
uses: actions/checkout@v2
141+
142+
- uses: ./.github/actions/deploy-service
143+
with:
144+
service: webhook-api
145+
image: ${{ needs.build-and-push-webhook-api.outputs.image }}
146+
cluster: ${{ env.CROWD_CLUSTER }}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Staging Deploy Webhook API
2+
3+
on:
4+
push:
5+
branches:
6+
- 'staging/**'
7+
- 'staging-**'
8+
paths:
9+
- 'services/libs/**'
10+
- 'services/apps/webhook_api/**'
11+
12+
env:
13+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
14+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
15+
CROWD_CLUSTER: ${{ secrets.STAGING_CLUSTER_NAME }}
16+
CROWD_ROLE_ARN: ${{ secrets.STAGING_CLUSTER_ROLE_ARN }}
17+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
18+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
19+
AWS_REGION: ${{ secrets.AWS_REGION }}
20+
SLACK_CHANNEL: deploys-staging
21+
SLACK_WEBHOOK: ${{ secrets.STAGING_SLACK_CHANNEL_HOOK }}
22+
23+
jobs:
24+
build-and-push:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
image: ${{ steps.image.outputs.IMAGE }}
28+
defaults:
29+
run:
30+
shell: bash
31+
32+
steps:
33+
- name: Check out repository code
34+
uses: actions/checkout@v2
35+
36+
- uses: ./.github/actions/build-docker-image
37+
id: image-builder
38+
with:
39+
image: webhook-api
40+
41+
- name: Set docker image output
42+
id: image
43+
run: echo "IMAGE=${{ steps.image-builder.outputs.image }}" >> $GITHUB_OUTPUT
44+
45+
deploy-webhook-api:
46+
needs: build-and-push
47+
runs-on: ubuntu-latest
48+
defaults:
49+
run:
50+
shell: bash
51+
52+
steps:
53+
- name: Check out repository code
54+
uses: actions/checkout@v2
55+
56+
- uses: ./.github/actions/deploy-service
57+
with:
58+
service: webhook-api
59+
image: ${{ needs.build-and-push.outputs.image }}
60+
cluster: ${{ env.CROWD_CLUSTER }}

backend/src/api/webhooks/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { safeWrap } from '../../middlewares/errorMiddleware'
22

33
export default (app) => {
4-
app.post(`/github`, safeWrap(require('./github').default))
4+
// app.post(`/github`, safeWrap(require('./github').default))
55
app.post(`/stripe`, safeWrap(require('./stripe').default))
66
app.post(`/sendgrid`, safeWrap(require('./sendgrid').default))
77
app.post(`/discourse/:tenantId`, safeWrap(require('./discourse').default))

scripts/builders/webhook-api.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
DOCKERFILE="./services/docker/Dockerfile.webhook_api"
4+
CONTEXT="../"
5+
REPO="crowddotdev/webhook-api"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM node:16-alpine as builder
2+
3+
RUN apk add --update --no-cache bash
4+
5+
WORKDIR /usr/crowd/app
6+
7+
# build libraries
8+
COPY ./services/scripts ./services/scripts
9+
COPY ./services/libs ./services/libs
10+
RUN cd services/scripts && ./install_lib_packages.sh && ./build_libs.sh && ./clear_lib_packages.sh
11+
12+
FROM node:16-alpine as release
13+
14+
RUN apk add --update --no-cache bash
15+
16+
WORKDIR /usr/crowd/app
17+
18+
ARG INSTALL_DEV_DEPENDENCIES="false"
19+
20+
COPY ./services/scripts ./services/scripts
21+
COPY --from=builder /usr/crowd/app/services/libs/ ./services/libs/
22+
RUN if [ "$INSTALL_DEV_DEPENDENCIES" = "false" ]; then export NPM_I_ENV_OPTS="--omit=dev"; fi && cd services/scripts && ./install_lib_packages.sh ${NPM_I_ENV_OPTS}
23+
24+
COPY ./services/apps/webhook_api/package.json ./services/apps/webhook_api/package-lock.json ./services/apps/webhook_api/tsconfig.json ./services/apps/webhook_api/
25+
COPY ./services/apps/webhook_api/config ./services/apps/webhook_api/config
26+
COPY ./services/apps/webhook_api/src ./services/apps/webhook_api/src
27+
28+
RUN if [ "$INSTALL_DEV_DEPENDENCIES" = "false" ]; then export NPM_I_ENV_OPTS="--omit=dev"; fi && cd services/apps/webhook_api && npm ci ${NPM_I_ENV_OPTS}
29+
30+
RUN npm cache clean --force
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
**/.git
2+
**/node_modules
3+
**/venv*
4+
**/.webpack
5+
**/.serverless
6+
**/.cubestore
7+
**/.env
8+
**/.env.*
9+
**/.idea
10+
**/.vscode
11+
**/dist
12+
backend/server-config/
13+
backend/util/
14+
backend/src/serverless/microservices/python
15+
.vscode/
16+
.github/
17+
frontend/
18+
scripts/
19+
.flake8
20+
*.md
21+
Makefile
22+
backend/

scripts/services/webhook-api.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
version: '3.1'
2+
3+
x-env-args: &env-args
4+
DOCKER_BUILDKIT: 1
5+
NODE_ENV: docker
6+
SERVICE: webhook-api
7+
SHELL: /bin/sh
8+
9+
services:
10+
webhook-api:
11+
build:
12+
context: ../../
13+
dockerfile: ./scripts/services/docker/Dockerfile.webhook_api
14+
command: 'npm run start'
15+
working_dir: /usr/crowd/app/services/apps/webhook_api
16+
env_file:
17+
- ../../backend/.env.dist.local
18+
- ../../backend/.env.dist.composed
19+
- ../../backend/.env.override.local
20+
- ../../backend/.env.override.composed
21+
environment:
22+
<<: *env-args
23+
ports:
24+
- '8082:8082'
25+
restart: always
26+
networks:
27+
- crowd-bridge
28+
29+
webhook-api-dev:
30+
build:
31+
context: ../../
32+
dockerfile: ./scripts/services/docker/Dockerfile.webhook_api
33+
args:
34+
INSTALL_DEV_DEPENDENCIES: 'true'
35+
command: 'npm run dev'
36+
working_dir: /usr/crowd/app/services/apps/webhook_api
37+
# user: '${USER_ID}:${GROUP_ID}'
38+
env_file:
39+
- ../../backend/.env.dist.local
40+
- ../../backend/.env.dist.composed
41+
- ../../backend/.env.override.local
42+
- ../../backend/.env.override.composed
43+
environment:
44+
<<: *env-args
45+
hostname: webhook-api
46+
ports:
47+
- '8082:8082'
48+
networks:
49+
- crowd-bridge
50+
volumes:
51+
- ../../services/libs/common/src:/usr/crowd/app/services/libs/common/src
52+
- ../../services/libs/database/src:/usr/crowd/app/services/libs/database/src
53+
- ../../services/libs/integrations/src:/usr/crowd/app/services/libs/integrations/src
54+
- ../../services/libs/logging/src:/usr/crowd/app/services/libs/logging/src
55+
- ../../services/libs/redis/src:/usr/crowd/app/services/libs/redis/src
56+
- ../../services/libs/sentiment/src:/usr/crowd/app/services/libs/sentiment/src
57+
- ../../services/libs/sqs/src:/usr/crowd/app/services/libs/sqs/src
58+
- ../../services/libs/types/src:/usr/crowd/app/services/libs/types/src
59+
- ../../services/apps/webhook_api/src:/usr/crowd/app/services/apps/webhook_api/src
60+
61+
networks:
62+
crowd-bridge:
63+
external: true

0 commit comments

Comments
 (0)