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
76 changes: 76 additions & 0 deletions .github/workflows/calico-github-issues-bot-trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Trigger Calico Github Issues Bot

on:
issues:
types: [opened]
issue_comment:
types: [created]

permissions:
contents: read
issues: read

jobs:
trigger-calico-github-issues-bot:
runs-on: ubuntu-latest
Comment thread
skoryk-oleksandr marked this conversation as resolved.

# Ignore PR comments and bot comments
if: >
(github.event_name == 'issues') ||
(
github.event_name == 'issue_comment' &&
github.event.issue.pull_request == null &&
github.event.comment.user.type != 'Bot'
)

steps:
- name: Print debug info
run: |
echo "Event: ${{ github.event_name }}"
echo "Issue number: ${{ github.event.issue.number }}"
echo "Comment ID: ${{ github.event.comment.id }}"
echo "Author: ${{ github.event.comment.user.login }}"
Comment thread
skoryk-oleksandr marked this conversation as resolved.

- name: Trigger Calico Github Issues Bot
env:
CALI_BOT_PAT: ${{ secrets.CALI_BOT_PAT }}
run: |
set -euo pipefail

if [ -z "$CALI_BOT_PAT" ]; then
echo "CALI_BOT_PAT is not set"
exit 1
fi

EVENT_TYPE=""
COMMENT_ID=""
COMMENT_AUTHOR=""

if [ "${{ github.event_name }}" = "issues" ]; then
EVENT_TYPE="issue_opened"
else
EVENT_TYPE="comment_created"
COMMENT_ID="${{ github.event.comment.id }}"
COMMENT_AUTHOR="${{ github.event.comment.user.login }}"
fi

echo "Dispatching Calico Github Issues Bot with event: $EVENT_TYPE"

curl --fail --show-error --silent -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $CALI_BOT_PAT" \
https://api.github.com/repos/tigera/cali-bot/actions/workflows/process-issue.yml/dispatches \
-d @- <<EOF
Comment thread
skoryk-oleksandr marked this conversation as resolved.
{
"ref": "main",
"inputs": {
"TRIGGER_EVENT": "$EVENT_TYPE",
"ISSUE_NUMBER": "${{ github.event.issue.number }}",
"COMMENT_ID": "$COMMENT_ID",
"COMMENT_AUTHOR": "$COMMENT_AUTHOR",
Comment thread
skoryk-oleksandr marked this conversation as resolved.
"TARGET_REPO": "${{ github.repository }}"
}
}
EOF

echo "Calico Github Issues Bot dispatch successful"