From 0dd2e3006977e92272ca7e353ba18eae6fc1266b Mon Sep 17 00:00:00 2001 From: beppeb Date: Mon, 20 Oct 2025 11:23:31 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20action.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..3f8e972 --- /dev/null +++ b/action.yml @@ -0,0 +1,42 @@ +name: 'PR Comment' +description: '在 Gitea PR 上添加评论' +author: 'Your Name' + +inputs: + body: + description: '评论内容' + required: true + token: + description: 'Gitea Token' + required: true + server: + description: 'Gitea 服务器地址(如 https://gitea.example.com)' + required: true + owner: + description: '仓库所有者' + required: true + repo: + description: '仓库名称' + required: true + pr_number: + description: 'PR 编号' + required: true + +runs: + using: "composite" + steps: + - name: Post Comment + shell: bash + run: | + BODY=$(cat <<'EOFMSG' + ${{ inputs.body }} + EOFMSG + ) + + ESCAPED=$(echo "$BODY" | jq -Rs .) + + curl -sS -X POST \ + -H "Authorization: token ${{ inputs.token }}" \ + -H "Content-Type: application/json" \ + -d "{\"body\": $ESCAPED}" \ + "${{ inputs.server }}/api/v1/repos/${{ inputs.owner }}/${{ inputs.repo }}/issues/${{ inputs.pr_number }}/comments" \ No newline at end of file