Skip to content
Merged
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
28 changes: 17 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,24 +219,30 @@ jobs:
env:
WEBHOOK: ${{ secrets.FEISHU_BOT_WEBHOOK }}
SIGNKEY: ${{ secrets.FEISHU_BOT_SIGNKEY }}
AT_BOT_OPEN_ID: ${{ secrets.FEISHU_AT_BOT_OPEN_ID }}
run: |
if [ -z "$WEBHOOK" ]; then
echo "FEISHU_BOT_WEBHOOK not set, skipping"
exit 0
fi
PR_LINK="${{ github.server_url }}/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
RUN_LINK="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
MSG="PR updated: ${{ github.repository }}#${{ github.event.pull_request.number }} | Format check: ${{ steps.status.outputs.status }}. Reply in this thread and @mention the integration-test bot to run integration test on private host. [View PR]($PR_LINK) | [View run]($RUN_LINK)"
BODY=""
if [ -n "$AT_BOT_OPEN_ID" ]; then
BODY=$(jq -n \
--arg line "$MSG" \
--arg oid "$AT_BOT_OPEN_ID" \
'{msg_type: "post", content: {post: {zh_cn: {title: "CI", content: [[{tag: "text", text: ($line + " ")}, {tag: "at", user_id: $oid}]]}}}}')
else
BODY=$(jq -n --arg text "$MSG" '{msg_type: "text", content: {text: $text}}')
fi
TS_NOW=$(date +%s)
TS_ISO=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
PAYLOAD=$(jq -nc \
--arg schema "ci_event_v1" \
--arg repo "${{ github.repository }}" \
--arg pr "${{ github.repository }}#${{ github.event.pull_request.number }}" \
--arg sha "${{ github.sha }}" \
--arg branch "${{ github.head_ref }}" \
--arg workflow "${{ github.workflow }}" \
--arg job "format-check" \
--arg run_url "$RUN_LINK" \
--arg conclusion "${{ steps.status.outputs.status }}" \
--arg ts_iso "$TS_ISO" \
--argjson timestamp "$TS_NOW" \
'{schema:$schema,repo:$repo,pr:$pr,sha:$sha,branch:$branch,workflow:$workflow,job:$job,run_url:$run_url,conclusion:$conclusion,ts_iso:$ts_iso,timestamp:$timestamp}' \
)
BODY=$(jq -n --arg text "$PAYLOAD" '{msg_type: "text", content: {text: $text}}')
if [ -n "$SIGNKEY" ]; then
TS=$(date +%s)
KEY=$(printf "%s\n%s" "$TS" "$SIGNKEY")
Expand Down
Loading