Skip to content
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
51 changes: 28 additions & 23 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,37 @@
}
},

"runArgs": ["--env-file", "${localWorkspaceFolder}/.env"],

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-azuretools.vscode-docker",
"eamodio.gitlens",
"kuscamara.yamllint-fix"
]
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-azuretools.vscode-docker",
"eamodio.gitlens",
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python 3.11.4
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.11.4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -59,6 +59,7 @@ jobs:
bottomly_google_api_key: ${{ secrets.GOOGLE_API_KEY }}
bottomly_google_cse_id: ${{ secrets.GOOGLE_CSE_ID }}
bottomly_slack_bot_token: ${{ secrets.SLACK_TOKEN }}
bottomly_slack_app_token: ${{ secrets.SLACK_APP_TOKEN }}
bottomly_prefix: _
bottomly_env: test
bottomly_mongo_conn_str: ${{ secrets.MONGO_CONN_STR }}
Expand Down
82 changes: 42 additions & 40 deletions .github/workflows/push_to_live.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
---
on:
release:
types:
- created
types: [created]
name: Push to Live

jobs:
build-and-deploy:
runs-on: ubuntu-latest

environment:
name: live

steps:
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: live
steps:
# checkout the repo
- name: 'Checkout GitHub Action'
uses: actions/checkout@main

- name: 'Login via Azure CLI'
uses: azure/login@v1.4.5
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: 'Build and push image'
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -f run.dockerfile -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}

- name: 'Deploy to Azure Container Instances'
uses: 'azure/aci-deploy@v1'
with:
resource-group: ${{ secrets.RESOURCE_GROUP }}
dns-name-label: ${{ secrets.RESOURCE_GROUP }}live${{ github.run_number }}
image: ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}
registry-login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
registry-username: ${{ secrets.REGISTRY_USERNAME }}
registry-password: ${{ secrets.REGISTRY_PASSWORD }}
name: bottomly-live
location: 'uk south'
environment-variables: bottomly_giphy_api_key=${{ secrets.GIPHY_API_KEY }} bottomly_google_api_key=${{ secrets.GOOGLE_API_KEY }} bottomly_google_cse_id=${{ secrets.GOOGLE_CSE_ID }} bottomly_slack_bot_token=${{ secrets.SLACK_TOKEN }} bottomly_prefix=${{ secrets.PREFIX }} bottomly_env=${{ secrets.ENV }} bottomly_mongo_conn_str=${{ secrets.MONGO_CONN_STR }} bottomly_github_token=${{ secrets.RELEASE_HISTORY_TOKEN }}
- name: Checkout GitHub Action
uses: actions/checkout@main
- name: Login via Azure CLI
uses: azure/login@v1.4.5
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Build and push image
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -f run.dockerfile -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}
- name: Deploy to Azure Container Instances
uses: azure/aci-deploy@v1
with:
resource-group: ${{ secrets.RESOURCE_GROUP }}
dns-name-label: ${{ secrets.RESOURCE_GROUP }}live${{ github.run_number }}
image: ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}
registry-login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
registry-username: ${{ secrets.REGISTRY_USERNAME }}
registry-password: ${{ secrets.REGISTRY_PASSWORD }}
name: bottomly-live
location: uk south
environment-variables: bottomly_giphy_api_key=${{ secrets.GIPHY_API_KEY }}
bottomly_google_api_key=${{ secrets.GOOGLE_API_KEY }}
bottomly_google_cse_id=${{ secrets.GOOGLE_CSE_ID }}
bottomly_slack_bot_token=${{ secrets.SLACK_TOKEN }}
bottomly_slack_app_token=${{ secrets.SLACK_APP_TOKEN }}
bottomly_prefix=${{ secrets.PREFIX }}
bottomly_env=${{ secrets.ENV }}
bottomly_mongo_conn_str=${{ secrets.MONGO_CONN_STR }}
bottomly_github_token=${{ secrets.RELEASE_HISTORY_TOKEN }}
80 changes: 41 additions & 39 deletions .github/workflows/push_to_test.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,48 @@
---
on: push

# release:
# types:
# - created
name: Push to Test

jobs:
build-and-deploy:
runs-on: ubuntu-latest

environment:
name: test

steps:
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: test
steps:
# checkout the repo
- name: 'Checkout GitHub Action'
uses: actions/checkout@main

- name: 'Login via Azure CLI'
uses: azure/login@v1.4.5
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: 'Build and push image'
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -f run.dockerfile -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}

- name: 'Deploy to Azure Container Instances'
uses: 'azure/aci-deploy@v1'
with:
resource-group: ${{ secrets.RESOURCE_GROUP }}
dns-name-label: ${{ secrets.RESOURCE_GROUP }}${{ github.run_number }}
image: ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}
registry-login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
registry-username: ${{ secrets.REGISTRY_USERNAME }}
registry-password: ${{ secrets.REGISTRY_PASSWORD }}
name: bottomly-test
location: 'uk south'
environment-variables: bottomly_giphy_api_key=${{ secrets.GIPHY_API_KEY }} bottomly_google_api_key=${{ secrets.GOOGLE_API_KEY }} bottomly_google_cse_id=${{ secrets.GOOGLE_CSE_ID }} bottomly_slack_bot_token=${{ secrets.SLACK_TOKEN }} bottomly_prefix=${{ secrets.PREFIX }} bottomly_env=${{ secrets.ENV }} bottomly_mongo_conn_str=${{ secrets.MONGO_CONN_STR }} bottomly_github_token=${{ secrets.RELEASE_HISTORY_TOKEN }}
- name: Checkout GitHub Action
uses: actions/checkout@main
- name: Login via Azure CLI
uses: azure/login@v1.4.5
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Build and push image
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -f run.dockerfile -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}
- name: Deploy to Azure Container Instances
uses: azure/aci-deploy@v1
with:
resource-group: ${{ secrets.RESOURCE_GROUP }}
dns-name-label: ${{ secrets.RESOURCE_GROUP }}${{ github.run_number }}
image: ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}
registry-login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
registry-username: ${{ secrets.REGISTRY_USERNAME }}
registry-password: ${{ secrets.REGISTRY_PASSWORD }}
name: bottomly-test
location: uk south
environment-variables: bottomly_giphy_api_key=${{ secrets.GIPHY_API_KEY }}
bottomly_google_api_key=${{ secrets.GOOGLE_API_KEY }}
bottomly_google_cse_id=${{ secrets.GOOGLE_CSE_ID }}
bottomly_slack_bot_token=${{ secrets.SLACK_TOKEN }}
bottomly_slack_app_token=${{ secrets.SLACK_APP_TOKEN }}
bottomly_prefix=${{ secrets.PREFIX }}
bottomly_env=${{ secrets.ENV }}
bottomly_mongo_conn_str=${{ secrets.MONGO_CONN_STR }}
bottomly_github_token=${{ secrets.RELEASE_HISTORY_TOKEN }}
6 changes: 6 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends: default

rules:
line-length: disable
truthy:
allowed-values: ['true', 'false', 'yes', 'no']
2 changes: 2 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ConfigKeys(Enum):
google_cse_id = "bottomly_google_cse_id"
mongo_conn_st = "bottomly_mongo_conn_str"
slack_bot_token = "bottomly_slack_bot_token"
slack_app_token = "bottomly_slack_app_token"
prefix = "bottomly_prefix"
giphy_api_key = "bottomly_giphy_api_key"
env_key = "bottomly_env"
Expand All @@ -23,6 +24,7 @@ class Config(object):
ConfigKeys.google_cse_id: 'Google custom search engine ID is not configured',
ConfigKeys.mongo_conn_st: 'MongoDB connection string is not configured',
ConfigKeys.slack_bot_token: 'Slack bot auth token is not configured',
ConfigKeys.slack_app_token: 'Slack app auth token is not configured',
ConfigKeys.prefix: "Standard command prefix is not configured",
ConfigKeys.giphy_api_key: "Giphy API key is not configured",
ConfigKeys.env_key: "Environment mode is not configured",
Expand Down
5 changes: 1 addition & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
from config import Config, ConfigKeys
import slack_channel.slack_event_handler

live_mode = "live"

if __name__ == '__main__':
is_debug = Config().get_config_value(ConfigKeys.env_key) != live_mode
slack_channel.slack_event_handler.handle_slack_context()
slack_channel.slack_event_handler.run_slack_socket_mode_client()
66 changes: 52 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,52 @@
aiohttp==3.7.4
pymongo==3.12.3
pymodm==0.4.3
google-api-python-client==1.6.5
slackclient==1.1.3
requests>=2.20.0
websocket-client==0.48.0
slacksocket==1.0.0
slack-sdk==3.4.0
beautifulsoup4==4.7.1
soupsieve==1.9
dnspython==1.16.0
dnslib==0.9.14
PyGithub==1.57
aiohappyeyeballs==2.6.1
aiohttp==3.13.3
aiosignal==1.4.0
async-timeout==5.0.1
attrs==25.4.0
beautifulsoup4==4.14.3
certifi==2026.2.25
cffi==2.0.0
chardet==6.0.0.post1
charset-normalizer==3.4.4
cryptography==46.0.5
dnslib==0.9.26
dnspython==2.8.0
frozenlist==1.8.0
google-api-core==2.30.0
google-api-python-client==2.190.0
google-auth==2.48.0
google-auth-httplib2==0.3.0
googleapis-common-protos==1.72.0
httplib2==0.31.2
idna==3.11
multidict==6.7.1
oauth2client==4.1.3
packaging==26.0
pip-review==1.3.0
propcache==0.4.1
proto-plus==1.27.1
protobuf==6.33.5
pyasn1==0.6.2
pyasn1_modules==0.4.2
pycparser==3.0
PyGithub==2.8.1
PyJWT==2.11.0
pymodm==0.4.3
pymongo==3.13.0
PyNaCl==1.6.2
pyparsing==3.3.2
requests==2.32.5
rsa==4.9.1
six==1.17.0
slack_sdk==3.40.1
slackclient==2.9.4
slacksocket==1.0.1
soupsieve==2.8.3
typing_extensions==4.15.0
uritemplate==4.2.0
urllib3==2.6.3
websocket-client==0.56.0
wrapt==2.1.1
yamllint==1.38.0
yamlfix==1.19.1
yarl==1.23.0
Loading
Loading