⚡ Trigger schutzbot using github actions
Signed-off-by: Major Hayden <major@redhat.com>
This commit is contained in:
parent
56c4922c8f
commit
51aa1c771c
2 changed files with 37 additions and 0 deletions
13
.github/workflows/tests.yml
vendored
13
.github/workflows/tests.yml
vendored
|
|
@ -53,6 +53,19 @@ jobs:
|
|||
- name: Send coverage to codecov.io
|
||||
run: bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
- name: Trigger Schutzbot
|
||||
env:
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
WEBHOOK_PAYLOAD: ${{ toJSON(github.event) }}
|
||||
SQS_REGION: us-east-1
|
||||
SQS_QUEUE_URL: "https://sqs.us-east-1.amazonaws.com/933752197999/schutzbot_webhook_sqs-staging"
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.WEBHOOK_AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.WEBHOOK_AWS_SECRET_ACCESS_KEY }}
|
||||
run: |
|
||||
#!/bin/bash
|
||||
pip3 install boto3
|
||||
schutzbot/send_webhook.py
|
||||
|
||||
shellcheck:
|
||||
name: "🐚 Shellcheck"
|
||||
runs-on: ubuntu-20.04
|
||||
|
|
|
|||
24
schutzbot/send_webhook.py
Executable file
24
schutzbot/send_webhook.py
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env python
|
||||
# Trigger a webhook event for Schutzbot using AWS SQS.
|
||||
import json
|
||||
import os
|
||||
|
||||
import boto3
|
||||
|
||||
WEBHOOK_PAYLOAD = os.environ.get("WEBHOOK_PAYLOAD")
|
||||
EVENT_NAME = os.environ.get("EVENT_NAME")
|
||||
SQS_REGION = os.environ.get("SQS_REGION")
|
||||
SQS_QUEUE_URL = os.environ.get("SQS_QUEUE_URL")
|
||||
|
||||
sqs = boto3.client('sqs', region_name=SQS_REGION)
|
||||
|
||||
payload = json.loads(WEBHOOK_PAYLOAD)
|
||||
message = {
|
||||
'headers': {'X-Github-Event': EVENT_NAME},
|
||||
'payload': payload
|
||||
}
|
||||
|
||||
response = sqs.send_message(
|
||||
QueueUrl=SQS_QUEUE_URL,
|
||||
MessageBody=json.dumps(message)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue