Skip to content

Commit 6259996

Browse files
committed
feat: add handling for team join event
1 parent 6c9429b commit 6259996

25 files changed

+17054
-2
lines changed

.commitlintrc.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'type-enum': [
5+
2,
6+
'always',
7+
[
8+
'feat',
9+
'fix',
10+
'docs',
11+
'style',
12+
'refactor',
13+
'perf',
14+
'test',
15+
'build',
16+
'ci',
17+
'chore',
18+
'revert'
19+
]
20+
]
21+
}
22+
};

.eslintrc.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
extends: [
4+
'eslint:recommended',
5+
'plugin:@typescript-eslint/recommended',
6+
'prettier'
7+
],
8+
plugins: ['@typescript-eslint'],
9+
env: {
10+
node: true,
11+
jest: true
12+
},
13+
rules: {
14+
'@typescript-eslint/explicit-function-return-type': 'off',
15+
'@typescript-eslint/no-explicit-any': 'warn',
16+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }]
17+
}
18+
};

.github/workflows/ci-cd.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [20.x]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
cache: 'npm'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Run linter
32+
run: npm run lint
33+
34+
- name: Run tests
35+
run: npm test
36+
37+
- name: Build
38+
run: npm run build
39+
40+
release:
41+
needs: test
42+
runs-on: ubuntu-latest
43+
if: github.ref == 'refs/heads/main'
44+
45+
steps:
46+
- uses: actions/checkout@v3
47+
with:
48+
fetch-depth: 0
49+
persist-credentials: false
50+
51+
- name: Setup Node.js
52+
uses: actions/setup-node@v3
53+
with:
54+
node-version: '18.x'
55+
56+
- name: Install dependencies
57+
run: npm ci
58+
59+
- name: Release
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
63+
run: npx semantic-release
64+
65+
deploy:
66+
needs: release
67+
runs-on: ubuntu-latest
68+
if: github.ref == 'refs/heads/main'
69+
70+
steps:
71+
- uses: actions/checkout@v3
72+
73+
- name: Deploy to Heroku
74+
uses: akhileshns/[email protected]
75+
with:
76+
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
77+
heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}
78+
heroku_email: ${{ secrets.HEROKU_EMAIL }}
79+
branch: main

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,12 @@ dist
128128
.yarn/build-state.yml
129129
.yarn/install-state.gz
130130
.pnp.*
131+
132+
# Node modules
133+
node_modules/
134+
dist/
135+
.env
136+
.env.*
137+
*.log
138+
.DS_Store
139+
coverage/

.husky/commit-msg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no -- commitlint --edit $1

.husky/pre-commit

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npm run lint
5+
npm test

.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 80,
6+
"tabWidth": 2
7+
}

.releaserc.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
branches: ['main'],
3+
plugins: [
4+
['@semantic-release/commit-analyzer', {
5+
preset: 'conventionalcommits',
6+
releaseRules: [
7+
{type: 'docs', scope: 'README', release: 'patch'},
8+
{type: 'refactor', release: 'patch'},
9+
{type: 'style', release: 'patch'},
10+
{type: 'perf', release: 'patch'},
11+
{type: 'chore', release: false}
12+
]
13+
}],
14+
'@semantic-release/release-notes-generator',
15+
['@semantic-release/changelog', {
16+
changelogFile: 'CHANGELOG.md'
17+
}],
18+
'@semantic-release/npm',
19+
['@semantic-release/git', {
20+
assets: ['package.json', 'CHANGELOG.md'],
21+
message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
22+
}],
23+
'@semantic-release/github'
24+
]
25+
};

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: npm start

README.md

+51-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,51 @@
1-
# slack-mailchimp-integration
2-
This integration adds a new user that signs up to your Slack workspace to a predefined Mailchimp mailing list
1+
# Slack-Mailchimp Integration
2+
3+
Automatically adds new Slack workspace members to a Mailchimp mailing list.
4+
5+
## Setup
6+
7+
1. Clone the repository
8+
2. Install dependencies:
9+
```bash
10+
npm install
11+
```
12+
3. Create a `.env` file with the following variables:
13+
```
14+
SLACK_BOT_TOKEN=xoxb-your-token
15+
SLACK_SIGNING_SECRET=your-signing-secret
16+
SLACK_APP_TOKEN=xapp-your-token
17+
MAILCHIMP_API_KEY=your-api-key
18+
MAILCHIMP_LIST_ID=your-list-id
19+
MAILCHIMP_SERVER_PREFIX=usX
20+
PORT=3000
21+
```
22+
23+
## Development
24+
25+
Run locally:
26+
27+
```
28+
curl -X POST https://immune-killdeer-enhanced.ngrok-free.app/slack/events \
29+
-H 'Content-Type: application/json' \
30+
-d '{
31+
"token": "your-verification-token",
32+
"team_id": "T123456",
33+
"api_app_id": "A123456",
34+
"event": {
35+
"type": "team_join",
36+
"user": {
37+
"id": "U123456",
38+
"team_id": "T123456",
39+
"name": "newuser",
40+
"real_name": "New User",
41+
"profile": {
42+
"email": "[email protected]"
43+
}
44+
}
45+
},
46+
"type": "event_callback",
47+
"event_id": "Ev123456",
48+
"event_time": 1234567890,
49+
"authed_users": ["U123456"]
50+
}
51+
```

jest.config.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
roots: ['<rootDir>/src'],
5+
testMatch: ['**/*.test.ts', '**/*.spec.ts'],
6+
transform: {
7+
'^.+\\.tsx?$': 'ts-jest'
8+
},
9+
coverageDirectory: 'coverage',
10+
collectCoverageFrom: [
11+
'src/**/*.{ts,tsx}',
12+
'!src/**/*.d.ts',
13+
'!src/types/**/*'
14+
]
15+
};

0 commit comments

Comments
 (0)