Skip to content

Commit

Permalink
Merge pull request #4969 from werf/ci-notify-commit-author
Browse files Browse the repository at this point in the history
ci: notify action actor
  • Loading branch information
distorhead committed Oct 3, 2022
2 parents 17da850 + 6148484 commit a5fdf4d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .github/workflows/_notification.yml
Expand Up @@ -14,6 +14,8 @@ on:
required: true
mentionUserID:
description: "Slack user ID to mention to (e.g. U0A19DD26)"
mapSlackUsers:
description: 'Mapping of GitHub users to Slack users. Contains lines of the following format: "github_username1:slack_memberID1"'
mentionGroupID:
description: "Slack group ID to mention to (e.g. SWS45DQ87)"

Expand Down Expand Up @@ -45,8 +47,19 @@ jobs:
- if: env.WORKFLOW_CONCLUSION == 'failure'
name: Add mentions
id: msg_mention
env:
ACTOR_NAME: ${{ github.triggering_actor }}
run: |
if [ -n "${{ secrets.mentionGroupID }}" ]; then MSG_MENTION_STRING="<!subteam^${{ secrets.mentionGroupID }}>"; fi
if [ -n "${{ secrets.mapSlackUsers }}" ]; then
ACTOR_SLACK_ID=$( echo '${{ secrets.mapSlackUsers }}' | ( grep "^${ACTOR_NAME:-:}": || true) | cut -d: -f2 | head -n 1 )
echo "::debug:: ACTOR_SLACK_ID is '${ACTOR_SLACK_ID}'."
if [ -n "$ACTOR_SLACK_ID" ]; then
MSG_MENTION_STRING="<@${ACTOR_SLACK_ID}>";
else
echo "Slack ID for ${ACTOR_NAME} was not found."
fi
fi
if [ -n "${{ secrets.mentionGroupID }}" ] && [ -z "${MSG_MENTION_STRING}" ]; then MSG_MENTION_STRING="<!subteam^${{ secrets.mentionGroupID }}>"; fi
if [ -n "${{ secrets.mentionUserID }}" ]; then MSG_MENTION_STRING="$MSG_MENTION_STRING${MSG_MENTION_STRING:+, }<@${{ secrets.mentionUserID }}>"; fi
echo "::debug:: Mention string - '$MSG_MENTION_STRING'."
echo "::set-output name=content::$MSG_MENTION_STRING"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_pr.yml
Expand Up @@ -66,4 +66,5 @@ jobs:
uses: ./.github/workflows/_notification.yml
secrets:
mentionGroupID: ${{ secrets.SLACK_MENTION_GROUP_ID }}
mapSlackUsers: ${{ secrets.SLACK_USERS_MAP }}
webhook: ${{ secrets.SLACK_WEBHOOK }}

0 comments on commit a5fdf4d

Please sign in to comment.