Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hold:Add task for deploying the instruct-lab-bot #19

Merged
merged 1 commit into from
Mar 14, 2024
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
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
Loading