-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script to redirect issues from datadog-agent (#27)
- Loading branch information
1 parent
164740e
commit 3f56c09
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: redirect | ||
|
||
on: | ||
schedule: | ||
- cron: "0 12 * * *" | ||
|
||
workflow_dispatch: # should be deleted after manual test | ||
|
||
jobs: | ||
redirect-issues: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Ping on slack issues related to serverless in the datadog-agent repo | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
run: ./scripts/redirect_issues.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
# Retrieve all issues from a repo | ||
|
||
yesterday=$(date --iso-8601=seconds --date="yesterday") | ||
|
||
GH_REPO_OWNER="DataDog" | ||
GH_REPO="datadog-agent" | ||
GH_URL="https://api.github.com/repos/$GH_REPO_OWNER/$GH_REPO/issues?since=$yesterday" | ||
|
||
SLACK_CHANNEL="#serverless" | ||
|
||
KEYWORDS="lambda|serverless|extension|layer" | ||
|
||
response=$(curl -H "Authorization: token $GH_TOKEN" -H "Accept: application/vnd.github.v3+json" -X GET "$GH_URL") | ||
echo "$response" | jq -c '.[]' | while read -r issue; do | ||
# Check if the retrieved issue is not a PR | ||
if [[ $(echo "${issue}" | jq '.pull_request') == "null" && \ | ||
( ! -z $(echo "${issue}" | jq '.body' | grep -E "$KEYWORDS") || \ | ||
! -z $(echo "${issue}" | jq '.title' | grep -E "$KEYWORDS") ) \ | ||
]]; then | ||
issue_url=$(echo "${issue}" | jq '.html_url') | ||
curl -H "Content-type: application/json" -X POST "$SLACK_WEBHOOK" -d '{"channel": "'$SLACK_CHANNEL'", "text": ":sos: '$issue_url'"}' | ||
fi | ||
done |