-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yaml
58 lines (54 loc) · 1.67 KB
/
action.yaml
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
name: 'Notes'
description: "Show note 'message' for 'ref'(note) & 'sha' if present. Add a message for the provided sha, if 'message' is present. https://git-scm.com/docs/git-notes"
inputs:
remote:
description: 'Remote to push'
default: "origin"
path:
description: 'Repository path'
default: "."
ref:
description: 'Note ref'
default: "commits"
sha:
description: 'Git object to attach note to'
required: true
message:
description: 'Note message'
override:
description: "Override note if 'true'"
default: false
name:
description: 'Config user.name'
default: "Git Notes Action"
email:
description: 'Config user.email'
default: "[email protected]"
outputs:
message:
description: 'Note message'
value: ${{ steps.note.outputs.message }}
runs:
using: "composite"
steps:
- id: note
name: Note
shell: bash {0}
run: |
pushd "${{ inputs.path }}"
{
git config user.name '${{ inputs.name }}'
git config user.email '${{ inputs.email }}'
git fetch origin "refs/notes/*:refs/notes/*" || true
} &> /dev/null
MESSAGE="$(git notes --ref=${{ inputs.ref }} show ${{ inputs.sha }} 2> /dev/null || echo "")"
echo "::set-output name=message::$MESSAGE"
if [[ -n "${{ inputs.message }}" ]]; then
OVERRIDE=""
if [[ "${{ inputs.override }}" == "true" ]]; then
OVERRIDE="-f"
fi
git notes --ref '${{ inputs.ref }}' add -m '${{ inputs.message }}' "${{ inputs.sha }}" $OVERRIDE
git push "${{ inputs.remote }}" "refs/notes/*"
fi
popd 1> /dev/null