-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
43 lines (43 loc) · 1.33 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
---
name: "Set bot Github user action"
description: "Action to set git commiter to a Github bot user"
author: "Maxwell G (@gotmax23)"
branding:
icon: user
color: green
inputs:
bot:
description: "Bot's user name"
default: "github-actions"
name:
description: "Name of the committer (user.name)"
global:
description: "Whether to set the config globally or only for the current repo"
working-directory:
description: "Directory in which to run commands"
default: "."
runs:
using: composite
steps:
- name: Set user and committer
shell: bash
env:
INPUT_BOT: "${{ inputs.bot }}"
INPUT_NAME: "${{ inputs.name || inputs.bot }}"
INPUT_GLOBAL: "${{ inputs.global }}"
INPUT_WORKING_DIRECTORY: "${{ inputs.working-directory }}"
SCRIPT: "${{ github.action_path }}/set_bot_user.sh"
run: |
set -euo pipefail
path="https://api.github.com/users/${INPUT_BOT}%5Bbot%5D"
user_id="$(curl -sS "${path}" | jq -r .id)"
args=()
if [[ "${INPUT_GLOBAL}" =~ (true|1) ]]; then
args+=("--global")
fi
cd "${INPUT_WORKING_DIRECTORY}"
set -x
git config "${args[@]}" \
user.name "${INPUT_NAME}"
git config "${args[@]}" \
user.email "${user_id}+${INPUT_BOT}[bot]@users.noreply.github.com"