From 95c6d2ab8cbd862261a34a650cfc99539532dbc4 Mon Sep 17 00:00:00 2001 From: nsingh-branch Date: Tue, 10 Oct 2023 13:49:34 -0700 Subject: [PATCH] Updated action to tag on-call engineer --- .github/workflows/dependabot-merger.yml | 30 +++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dependabot-merger.yml b/.github/workflows/dependabot-merger.yml index 207b100ed..d68ade904 100644 --- a/.github/workflows/dependabot-merger.yml +++ b/.github/workflows/dependabot-merger.yml @@ -10,6 +10,32 @@ jobs: runs-on: ubuntu-latest steps: + - name: Get current on-call + id: on-call + run: | + now=$(date -u +%Y-%m-%dT%H:%M:%SZ) + end_time=$(date -u -d '+24 hour' +%Y-%m-%dT%H:%M:%SZ) + + oncall=$(curl --request GET \ + --url "https://api.pagerduty.com/oncalls?since=$now&until=$end_time&schedule_ids[]=PQLHTOP" \ + --header 'Accept: application/vnd.pagerduty+json;version=2' \ + --header "Authorization: Token token=u+Rx17kSFaAf8vDt-Lhg" \ + --header 'Content-Type: application/json' ) + + engineer_name=$(echo "$oncall" | jq -r '.oncalls[0].user.summary') + + declare -A engineer_to_slackid + engineer_to_slackid=( + ["Nipun Singh"]="U02AMC70R6E" + ["Jagadeesh Karicherla"]="U038BDE0XUZ" + ["Gabe De Luna"]="U02MDA0PHK5" + ["Ernest Cho"]="UCV77QDSL" + ["Nidhi Dixit"]="U02GDFBP88N" + ) + + slack_id=${engineer_to_slackid["$engineer_name"]} + echo "oncall_slack_id=$slack_id" >> $GITHUB_OUTPUT + - name: Create PR uses: actions/github-script@v6 id: create-pr @@ -108,7 +134,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*Included PRs:*\n${{ steps.create-pr.outputs.pr_list }}" + "text": "*Included PRs:*\n${{ steps.create-pr.outputs.pr_list }}\n\n\nCurrent On-Call: *<${{ steps.on-call.outputs.oncall_slack_id }}>*" } }, { @@ -118,7 +144,7 @@ jobs: "type": "button", "text": { "type": "plain_text", - "text": "github-pull-request-open: View Combined PR", + "text": ":github-pull-request-open: View Combined PR", "emoji": true }, "value": "pr-button",