Skip to content

Commit 48e3bb0

Browse files
author
Ashwin Kumar
committed
test e2e on label
1 parent 3c4d29e commit 48e3bb0

File tree

4 files changed

+1128
-970
lines changed

4 files changed

+1128
-970
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: 'Set Status'
2+
description: 'Set status on a specified head-sha'
3+
inputs:
4+
context:
5+
description: 'Name of the status'
6+
required: true
7+
description:
8+
description: 'Short description of the status'
9+
required: false
10+
state:
11+
description: >-
12+
State of the status with possible values of 'error', 'failure', 'pending', 'success'
13+
required: true
14+
sha:
15+
description: 'The commit ID to add the status to'
16+
required: true
17+
target-url:
18+
description: >-
19+
Target URL to associate with this status.
20+
This URL will be linked from the GitHub UI to allow users to easily see the source of the status.'
21+
required: false
22+
runs:
23+
using: 'composite'
24+
steps:
25+
- name: Set a commit status
26+
id: set-status
27+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 https://github.com/actions/github-script/commit/60a0d83039c74a4aee543508d2ffcb1c3799cdea
28+
env:
29+
status_context: ${{ inputs.context }}
30+
description: ${{ inputs.description }}
31+
state: ${{ inputs.state }}
32+
sha: ${{ inputs.sha }}
33+
target_url: ${{ inputs.target-url }}
34+
owner: ${{ github.event.repository.owner.login }}
35+
repo: ${{ github.event.repository.name }}
36+
with:
37+
result-encoding: string
38+
script: |
39+
const { status_context, description, state, sha, target_url, owner, repo } = process.env;
40+
const inputValidationErrors = [];
41+
if (state.length === 0) {
42+
inputValidationErrors.push('"state" input cannot be empty.');
43+
}
44+
if (!["error", "failure", "pending", "success"].includes(state)) {
45+
inputValidationErrors.push('"state" must be a string input with possible value of "error", "failure", "pending", "success".');
46+
}
47+
if (context.length === 0) {
48+
inputValidationErrors.push('"context" input cannot be empty.');
49+
}
50+
if (sha.length === 0) {
51+
inputValidationErrors.push('"sha" input cannot be empty.');
52+
}
53+
if (!sha.match(/^[0-9a-z]+$/)) {
54+
inputValidationErrors.push('"sha" must be an alphanumeric string.');
55+
}
56+
if (inputValidationErrors.length > 0) {
57+
inputValidationErrors.forEach(core.error);
58+
process.exit(1);
59+
}
60+
github.rest.repos.createCommitStatus({
61+
owner,
62+
repo,
63+
sha,
64+
state,
65+
context: status_context,
66+
description: description.length > 0 ? description : undefined,
67+
target_url: target_url.length > 0 ? target_url : undefined,
68+
});

0 commit comments

Comments
 (0)