-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yml
More file actions
107 lines (99 loc) · 3.73 KB
/
action.yml
File metadata and controls
107 lines (99 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
name: Generate suggestion from the knowledge base of the documentation bot
description: >
The action uses the Espressif Chatbot and its knowledge base for automatically answering Github issues.
inputs:
in_msg:
description: Issue message which will be handed over to the bot for evaluation.
required: true
title:
description: Issue title.
required: false
default: ''
bot_query_prefix:
description: The issue message can be prefixed with this string before evaluation.
required: false
default: >
The customer opened a Github issue with the following information. Please help and I'll post your answer there.
github_comments:
description: If set to false, the bot will not post a reply to the issue.
default: true
required: false
github_token:
description: Access token for the repository when the workflow is run. It will be used by the bot to post a reply.
required: false
github_repository:
description: Repository where the workflow is run.
required: false
github_issue_number:
description: Issue number in the repository from where in_msg is coming from.
required: false
prefix_out_msg:
description: Post this message together with the bot's response. Can be used for warnings, disclaimers and similar.
required: false
default: ''
runs:
using: composite
steps:
- name: Check if action is allowed to be run
if: ${{ github.repository_owner != 'espressif' }}
shell: bash
run: |
echo "Using this action from outside the organization is not supported"
exit 1
- name: Checkout action repository
uses: actions/checkout@v4
with:
repository: espressif/docs-bot-action
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: pip
- name: Install Python dependencies
shell: bash
run: |
python -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
- name: Run bot_action.py
shell: bash
id: bot-action
env:
INPUT_BOT_QUERY_PREFIX: ${{ inputs.bot_query_prefix }}
INPUT_TITLE: ${{ inputs.title }}
INPUT_IN_MSG: ${{ inputs.in_msg }}
INPUT_PREFIX_OUT_MSG: ${{ inputs.prefix_out_msg }}
INPUT_GITHUB_REPOSITORY: ${{ inputs.github_repository }}
INPUT_ISSUE_NUMBER: ${{ inputs.github_issue_number }}
run: |
source venv/bin/activate
if [ -n "$INPUT_GITHUB_REPOSITORY" ] && [ -n "$INPUT_ISSUE_NUMBER" ]; then
GITHUB_LINK="https://github.com/${INPUT_GITHUB_REPOSITORY}/issues/${INPUT_ISSUE_NUMBER}"
else
GITHUB_LINK="N/A"
fi
printf '%s\nIssue asked at: %s\nIssue title: %s\nIssue body:\n%s\n' "$INPUT_BOT_QUERY_PREFIX" "$GITHUB_LINK" "$INPUT_TITLE" "$INPUT_IN_MSG" > input.txt
printf '%s\n' "$INPUT_PREFIX_OUT_MSG" > output.txt
printf '\n---\n' >> output.txt
python bot_action/bot_action.py input.txt >> output.txt || exit 1
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: text-files
retention-days: 5
path: |
output.txt
input.txt
- name: Comment
if: ${{ inputs.github_comments == 'true' }}
shell: bash
env:
GH_TOKEN: ${{ inputs.github_token }}
GH_REPO: ${{ inputs.github_repository }}
ISSUE_NUMBER: ${{ inputs.github_issue_number }}
run: |-
# --edit-last will fail if there is no previous comment by the bot. See https://github.com/cli/cli/issues/10370
gh issue comment "$ISSUE_NUMBER" --body-file output.txt --edit-last || \
gh issue comment "$ISSUE_NUMBER" --body-file output.txt