-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
93 lines (86 loc) · 2.89 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Bot Defaults
author: Daniel Cazzulino
description: |
A GitHub action that sets git defaults (name, email, author) for
automated bot workflows from secrets or env vars.
inputs:
name:
description: The default name of the bot account. Defaults to $GITHUB_ACTOR.
required: false
default: ${{ github.actor }}
email:
description: The default email of the bot account. Defaults to [email protected].
required: false
default: '${{ github.actor }}@users.noreply.github.com'
gh_token:
description: The token to set as $GH_TOKEN environment variable.
required: false
default: ''
github_token:
description: Fallback token to use for $GH_TOKEN if gh_token is empty.
required: false
default: ${{ github.token }}
branding:
icon: "edit-3"
color: "purple"
runs:
using: "composite"
steps:
- name: 🤖 defaults
shell: bash
run: |
if [ -z "$GH_TOKEN" ]
then
if [ -z "${{ inputs.gh_token }}" ]
then
if [ -z "${{ inputs.github_token }}" ]
then
echo "Either gh_token or github_token must have a value."
exit 1
fi
echo "Using github_token from inputs"
echo "GH_TOKEN=${{ inputs.github_token }}" >> $GITHUB_ENV
echo "bot-token=${{ inputs.github_token }}" >> $GITHUB_OUTPUT
else
echo "Using gh_token from inputs"
echo "GH_TOKEN=${{ inputs.gh_token }}" >> $GITHUB_ENV
echo "bot-token=${{ inputs.gh_token }}" >> $GITHUB_OUTPUT
fi
else
echo "bot-token=$GH_TOKEN" >> $GITHUB_OUTPUT
fi
if [ -z "$BOT_NAME"]
then
if [ -z "${{ inputs.name }}" ]
then
echo "Using default GITHUB_ACTOR as BOT_NAME"
BOT_NAME="$GITHUB_ACTOR"
else
echo "Using custom name from inputs"
BOT_NAME="${{ inputs.name }}"
fi
echo "BOT_NAME=$BOT_NAME" >> $GITHUB_ENV
fi
echo "bot-name=$BOT_NAME" >> $GITHUB_OUTPUT
if [ -z "$BOT_EMAIL"]
then
if [ -z "${{ inputs.email }}" ]
then
echo "Using default email as BOT_EMAIL"
BOT_EMAIL="[email protected]"
else
echo "Using custom email from inputs"
BOT_EMAIL="${{ inputs.email }}"
fi
echo "BOT_EMAIL=$BOT_EMAIL" >> $GITHUB_ENV
fi
echo "bot-email=$BOT_EMAIL" >> $GITHUB_OUTPUT
if [ -z "$BOT_AUTHOR"]
then
echo "Using default BOT_NAME <BOT_EMAIL> as BOT_AUTHOR"
BOT_AUTHOR="$BOT_NAME <$BOT_EMAIL>"
echo "BOT_AUTHOR=$BOT_AUTHOR" >> $GITHUB_ENV
fi
echo "bot-author=$BOT_AUTHOR" >> $GITHUB_OUTPUT
git config --global user.name $BOT_NAME
git config --global user.email $BOT_EMAIL