Skip to content

Commit

Permalink
Merge pull request #19 from vishnoianil/ghbot
Browse files Browse the repository at this point in the history
Hold:Add task for deploying the instruct-lab-bot
  • Loading branch information
dave-tucker authored Mar 14, 2024
2 parents 3ad10cf + 2f1668c commit c50d089
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions deploy/ansible/deploy-ec2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
git_repo: [email protected]:instruct-lab/cli.git
python_venv_path: "{{ ansible_env.HOME }}/venv"
app_directory: "{{ ansible_env.HOME }}/cli"
ghbot_directory: "{{ ansible_env.HOME }}/instruct-lab-bot"
models_directory: "{{ app_directory }}/models"
new_model_path: "models/mistral-7b-instruct-v0.1.Q4_K_M.gguf"
roles:
Expand Down
62 changes: 62 additions & 0 deletions deploy/ansible/deploy-lab/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,68 @@
state: present
become: yes

- name: Install pm2 using npm
ansible.builtin.npm:
name: pm2
global: yes
become: yes

- name: Check if the instruct-lab-bot directory exists
stat:
path: {{ ghbot_directory }}/instruct-lab-bot
register: instruct_lab_bot_dir

- name: Delete the instruct-lab-bot directory if it exists
file:
path: {{ ghbot_directory }}/instruct-lab-bot
state: absent
when: instruct_lab_bot_dir.stat.exists

- name: Clone the instruct-lab-bot repository
git:
repo: https://github.com/redhat-et/instruct-lab-bot
dest: {{ ghbot_directory }}/instruct-lab-bot
clone: yes
update: yes

- name: Install instruct lab bot dependencies
ansible.builtin.shell: |
cd {{ ghbot_directory }}
npm install
args:
executable: /bin/bash

- name: Setup environment variables for instruct lab bot
ansible.builtin.shell: |
cd {{ ghbot_directory }}
echo "export GITHUB_TOKEN={{ github_token }}" > .env
args:
executable: /bin/bash

- name: Setup environment variables for instruct lab bot
vars:
env_file_path: {{ ghbot_directory }}/.env
tasks:
- name: Ensure key-value pairs are in .env file
ansible.builtin.lineinfile:
path: "{{ env_file_path }}"
line: "{{ item.key }}={{ item.value }}"
insertafter: EOF
loop:
- { key: "WEBHOOK_PROXY_URL", value: ${{ secrets.WEBHOOK_PROXY_URL }} }
- { key: "APP_ID", value: ${{ secrets.APP_ID }} }
- { key: "PRIVATE_KEY", value: ${{ secrets.PRIVATE_KEY }} }
- { key: "WEBHOOK_SECRET", value: ${{ secrets.WEBHOOK_SECRET }} }
- { key: "GITHUB_CLIENT_ID", value: ${{ secrets.GITHUB_CLIENT_ID }} }
- { key: "GITHUB_CLIENT_SECRET", value: ${{ secrets.GITHUB_CLIENT_SECRET }} }

- name: Run the instruct lab bot
ansible.builtin.shell: |
cd {{ ghbot_directory }}
pm2 start npm --name "ghbot" -- start
args:
executable: /bin/bash

- name: Check if the cli directory exists
stat:
path: /home/{{ ansible_user }}/cli
Expand Down

0 comments on commit c50d089

Please sign in to comment.