-
Notifications
You must be signed in to change notification settings - Fork 3
/
action.yaml
114 lines (107 loc) · 3.4 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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
name: "gerrit-review"
description: "Set review votes on a Gerrit system"
inputs:
host:
description: "The Gerrit host with SSH available"
required: true
port:
description: "The SSH port to use. Default 29418"
required: false
default: "29418"
username:
description: "The username to connect to the Gerrit host as"
required: true
key:
description: "The SSH private key to use"
required: true
key_name:
description: "The filename for the key, defaults to id_rsa"
required: false
default: "id_rsa"
known_hosts:
description: "The known hosts for the host server"
required: true
gerrit-change-number:
description: "The Gerrit Change Number that is being voted against"
required: true
gerrit-patchset-number:
description: "The patchset number of the change that is being voted against"
required: false
default: "1"
vote-type:
description: "The type of vote to perform: clear, success, failure, cancelled"
required: false
default: "clear"
comment-only:
description: "Should the review only post a comment and not a vote"
required: false
default: "false"
runs:
using: "composite"
steps:
- name: Install SSH Key
if: ${{ !env.ACT }}
uses: shimataro/ssh-key-action@d4fffb50872869abe2d9a9098a6d9c5aa7d16be4 # v2.7.0
with:
key: ${{ inputs.key }}
name: ${{ inputs.key_name }}
known_hosts: ${{ inputs.known_hosts }}
config: |
Host ${{ inputs.host }}
User ${{ inputs.username }}
Port ${{ inputs.port }}
PubkeyAcceptedKeyTypes +ssh-rsa
IdentityFile ~/.ssh/${{ inputs.key_name }}
- name: Clear
if: "${{ inputs.vote-type == 'clear' }}"
shell: bash
run: |
if [[ "${{ inputs.comment-only }}" == "false" ]]; then
VOTE="--label Verified=0 --label Code-Review=0"
else
VOTE=""
fi
echo "VOTE=${VOTE}" >> "$GITHUB_ENV"
echo "STATUS=STARTED" >> "$GITHUB_ENV"
- name: Success
if: "${{ inputs.vote-type == 'success' }}"
shell: bash
run: |
if [[ "${{ inputs.comment-only }}" == "false" ]]; then
VOTE="--label Verified=1"
else
VOTE=""
fi
echo "VOTE=${VOTE}" >> "$GITHUB_ENV"
echo "STATUS=SUCCESS" >> "$GITHUB_ENV"
- name: Failure
if: "${{ inputs.vote-type == 'failure' }}"
shell: bash
run: |
if [[ "${{ inputs.comment-only }}" == "false" ]]; then
VOTE="--label Verified=-1"
else
VOTE=""
fi
echo "VOTE=${VOTE}" >> "$GITHUB_ENV"
echo "STATUS=FAILURE" >> "$GITHUB_ENV"
- name: Cancelled
if: "${{ inputs.vote-type == 'cancelled' }}"
shell: bash
run: |
if [[ "${{ inputs.comment-only }}" == "false" ]]; then
VOTE="--label Code-Review=1"
else
VOTE=""
fi
echo "VOTE=${VOTE}" >> "$GITHUB_ENV"
echo "STATUS=CANCELLED" >> "$GITHUB_ENV"
- name: Vote
if: ${{ !env.ACT }}
shell: bash
run: |
MESSAGE="${STATUS}: ${{ github.server_url }}/${{ github.repository}}/actions/runs/${{ github.run_id }}"
PATCH="${{ inputs.gerrit-change-number}},${{ inputs.gerrit-patchset-number }}"
COMMAND="review ${PATCH} --message '${MESSAGE}' ${VOTE} --tag autogenerated:github"
ssh ${{ inputs.host }} gerrit "${COMMAND}"