-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
36 lines (31 loc) · 1.15 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: User Email Action
author: DevOps
description: Attempts to retrieve an email address associated with the user running the workflow
inputs:
token:
description: 'GitHub token'
outputs:
email:
description: 'Resulting email address. Default is committer.'
value: ${{ steps.email.outputs.address }}
runs:
using: 'composite'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags
- name: Get email(s) associated with user
id: email
shell: bash
run: |
ACTOR=${{ github.actor }}
USER_EMAIL=$(curl -s -H "Authorization: token ${{ inputs.token }}" https://api.github.com/users/$ACTOR | jq -r .email)
echo "User email: $USER_EMAIL"
patriot_email=$(echo "$USER_EMAIL" | grep -i "@patriotsoftware.com")
if [ "$USER_EMAIL" == "null" ] || [ -z "$patriot_email"]; then
echo "No Patriot email address found for user $ACTOR $USER_EMAIL Using committer."
echo "address=committer" >> $GITHUB_OUTPUT
else
echo "Patriot email(s) for the user $ACTOR: $patriot_email"
echo "address=$patriot_email" >> $GITHUB_OUTPUT
fi