Skip to content

Commit

Permalink
Update push-trigger.yml
Browse files Browse the repository at this point in the history
Signed-off-by: bn46 <[email protected]>
  • Loading branch information
bn46 authored Oct 9, 2024
1 parent 636ebc2 commit 6daf288
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/push-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,26 @@ jobs:
- name: Decode Slack Users Secret
id: slack_id
run: |
# Decode the JSON string from the secret
# Access the JSON string from the secret
SLACK_USERS_MAP="${{ secrets.SLACK_USERS_MAP }}"
# Extract GitHub username of the PR author
GITHUB_USER="${{ github.event.pull_request.user.login }}"
# Use jq to extract the Slack ID corresponding to the GitHub username
SLACK_USER_ID=$(echo "$SLACK_USERS_MAP" | jq -r --arg github_user "${{ env.author }}" '.[$github_user]')
SLACK_USER_ID=$(echo "$SLACK_USERS_MAP" | jq -r --arg github_user "$GITHUB_USER" '.[$github_user]')
# Check if the Slack user ID was found
if [ -z "$SLACK_USER_ID" ] || [ "$SLACK_USER_ID" == "null" ]; then
echo "Slack user ID not found for GitHub user: ${{ env.author }}"
echo "Slack user ID not found for GitHub user: $GITHUB_USER"
exit 1
fi
# Export the Slack user ID to the GitHub environment
echo "SLACK_USER_ID=$SLACK_USER_ID" >> $GITHUB_ENV
shell: bash

- name: Post to a Slack channel
id: slack
uses: slackapi/[email protected]
Expand Down

0 comments on commit 6daf288

Please sign in to comment.