Skip to content

Commit

Permalink
Merge branch 'features/self-deploy-PRE' into actions/replacebot-v3-sd1
Browse files Browse the repository at this point in the history
# Conflicts:
#	tybotRoute/CHANGELOG.md
#	tybotRoute/package-lock.json
#	tybotRoute/package.json
  • Loading branch information
Giovanni Troisi committed Jan 9, 2025
2 parents 33510fb + a216f6d commit fe0902f
Show file tree
Hide file tree
Showing 50 changed files with 1,022 additions and 538 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/docker-community-push-latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Docker Image Community latest CI - Tiledesk Chatbot

env:
REGISTRY: tiledeskrepo
IMAGE_NAME: tiledesk-chatbot

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
48 changes: 48 additions & 0 deletions .github/workflows/docker-image-tag-community-tag-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish Docker Community image tags - Tiledesk Chatbot

env:
REGISTRY: tiledeskrepo
IMAGE_NAME: tiledesk-chatbot

on:
push:
tags:
- '**' # Push events to every tag including hierarchical tags like

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3

with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tag_with_ref: true

- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
- name: Build and push
uses: docker/build-push-action@v4

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Tiledesk native chatbot

### 0.1.1 updated MarckbotPlugs.js & DirectivesPlug.js

# 1.0.2
- bug-fixed: default engine for DirAskGPTV2
- bug-fixed: block only hidden message

# 1.0.1
- first deploy of Chatbot Plugs

### 0.1.1 updated MarckbotPlugs.js & DirectivesPlug.js
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM node:16

RUN sed -i 's/stable\/updates/stable-security\/updates/' /etc/apt/sources.list


RUN apt-get update

# Create app directory
WORKDIR /usr/src/app

ARG NPM_TOKEN

RUN if [ "$NPM_TOKEN" ]; \
then RUN COPY .npmrc_ .npmrc \
else export SOMEVAR=world; \
fi


# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install --production

RUN rm -f .npmrc

# Bundle app source
COPY . .

EXPOSE 3000

CMD [ "npm", "start" ]

20 changes: 20 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#npm version patch
version=`node -e 'console.log(require("./package.json").version)'`
echo "version $version"

## Update package-lock.json
npm install

## Push commit to git
git add .
git commit -m "version added: ### $version"
git push remote master

## Create tag and npm
if [ "$version" != "" ]; then
git tag -a "$version" -m "`git log -1 --format=%s`"
echo "Created a new tag, $version"
git push --tags
cd ./tybotRoute
npm publish --access public
fi
22 changes: 12 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@ var app = express();
var cors = require('cors');
app.use(cors());

//const tybot = require("@tiledesk/tiledesk-tybot-connector");
// const tybot = require("@tiledesk/tiledesk-tybot-connector");
const tybot = require("./tybotRoute");
const templates = require("./templatesRoute");
const chooser_bot = require("./chooserChatbotRoute");
const tybotRoute = tybot.router;
const templatesRoute = templates.router;
const chooserRoute = chooser_bot.router;
app.use("/", tybotRoute); // /tybot

const templates = require("./templatesRoute");
const templatesRoute = templates.router;
app.use("/chatbots", templatesRoute);
app.use("/langbot", chooserRoute);

// const chooser_bot = require("./chooserChatbotRoute");
// const chooserRoute = chooser_bot.router;
// app.use("/langbot", chooserRoute);

// TEMP
// const bots_data = require('./tybotRoute/test/conversation-actions_bot.js').bots_data;

tybot.startApp(
{
MONGODB_URI: process.env.mongoUrl,
MONGODB_URI: process.env.MONGODB_URI,
// bots: bots_data,
API_ENDPOINT: process.env.API_ENDPOINT,
REDIS_HOST: process.env.REDIS_HOST,
REDIS_PORT: process.env.REDIS_PORT,
REDIS_PASSWORD: process.env.REDIS_PASSWORD,
REDIS_HOST: process.env.CACHE_REDIS_HOST,
REDIS_PORT: process.env.CACHE_REDIS_PORT,
REDIS_PASSWORD: process.env.CACHE_REDIS_PASSWORD,
// CACHE_ENABLED: process.env.CACHE_ENABLED,
log: process.env.TILEBOT_LOG
}, () => {
Expand Down
Loading

0 comments on commit fe0902f

Please sign in to comment.