Skip to content

Commit b353c92

Browse files
authored
actions/github/env/summary: Add back missing action (#3375)
Signed-off-by: Ryan Northey <[email protected]>
1 parent ae45ba3 commit b353c92

File tree

3 files changed

+355
-0
lines changed

3 files changed

+355
-0
lines changed

actions/github/env/load/action.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
inputs:
2+
head-sha:
3+
type: string
4+
default:
5+
name:
6+
type: string
7+
default: env
8+
run-id:
9+
type: string
10+
default:
11+
check-name:
12+
type: string
13+
default:
14+
template-check-text:
15+
type: string
16+
default: |
17+
## \($icon) Check is running
18+
19+
## The check run can be viewed here:
20+
21+
# \($icon) [\($data.check.name) (\($summary.title))](\($runLink))
22+
23+
template-script-current:
24+
type: string
25+
default: |
26+
OUTPUT=\"$(gh api --jq '.workflow_runs[0].id' repos/\($repo)/actions/workflows/request.yml/runs?head_sha=\($head_sha))\"
27+
28+
outputs:
29+
data:
30+
value: ${{ steps.data.outputs.value }}
31+
output:
32+
value: ${{ steps.toenv.outputs.value }}
33+
34+
35+
runs:
36+
using: composite
37+
steps:
38+
# For dispatch events we have to find the request via the Request workflow
39+
- uses: envoyproxy/toolshed/gh-actions/bson@2d46e676172c17700ec475a69ae0893eb55b484d
40+
name: Find request
41+
id: find-request
42+
if: ${{ inputs.head-sha }}
43+
with:
44+
filter: |
45+
"${{ github.repository }}" as $repo
46+
| "${{ inputs.head-sha }}" as $head_sha
47+
| ("${{ inputs.template-script-current }}" | bash::output)
48+
- name: Download environment data
49+
id: download
50+
uses: envoyproxy/toolshed/gh-actions/github/artifact/download@2d46e676172c17700ec475a69ae0893eb55b484d
51+
with:
52+
name: ${{ inputs.name }}
53+
path: ${{ runner.temp }}
54+
run-id: ${{ steps.find-request.outputs.output || inputs.run-id }}
55+
56+
- name: Validate environment source
57+
if: ${{ github.event_name == 'workflow_run' }}
58+
uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d
59+
with:
60+
input: |
61+
workflow_event: ${{ toJSON(github.event.workflow_run.event) }}
62+
workflow_repo: ${{ toJSON(github.event.workflow_run.repository.full_name) }}
63+
current_repo: ${{ toJSON(github.repository) }}
64+
allowed_events: ["pull_request_target", "push", "schedule"]
65+
input-format: yaml
66+
print-output: true
67+
options: -r
68+
filter: |
69+
.workflow_event as $event
70+
| .workflow_repo as $repo
71+
| .current_repo as $current
72+
| .allowed_events as $allowed
73+
# Check that the workflow run came from the same repository
74+
| if $repo != $current then
75+
error("Environment artifact must come from the same repository. Expected: \($current), Got: \($repo)")
76+
# Check that the workflow run was triggered by an allowed event
77+
elif ($allowed | index($event)) == null then
78+
error("Environment artifact must come from an allowed event type. Allowed: \($allowed), Got: \($event)")
79+
else
80+
"✓ Environment source validation passed"
81+
end
82+
- uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d
83+
name: Load env data
84+
id: data
85+
with:
86+
input-format: json-path
87+
input: ${{ runner.temp }}/${{ inputs.name }}.json
88+
# This is hardcoded to allow use of input templates
89+
filter: |
90+
"${{ inputs.check-name }}" as $checkName
91+
| .check = .checks["\($checkName)"]
92+
| del(.checks)
93+
| . as $data
94+
| $data.summary as $summary
95+
| "${{ github.event.workflow_run.conclusion }}" as $conclusion
96+
| "${{ github.run_id }}" as $runId
97+
| "${{ github.repository }}" as $repo
98+
| if $conclusion != "" and $conclusion != "success"
99+
then "completed"
100+
else "in_progress" end
101+
| . as $status
102+
| $data.config.envoy.icon as $icon
103+
| "https://github.com/\($repo)/actions/runs/\($runId)" as $runLink
104+
| "${{ inputs.template-check-text }}" as $text
105+
| {name: $data.check.name,
106+
head_sha: $data.request.sha,
107+
status: $status,
108+
external_id: "\($runId)",
109+
output: {
110+
summary: "Check is running",
111+
title: "\($data.check.name) (\($status))",
112+
text: $text}}
113+
| if $data.check.id and $data.check.id != "" and $status == "completed" then
114+
.conclusion = "cancelled"
115+
else . end
116+
| . as $check
117+
| $data.run
118+
| if $data.check["check-id"] and $status == "completed" then
119+
with_entries(.value = false)
120+
else . end
121+
| . as $run
122+
| $data
123+
| .run = $run
124+
| {$check,
125+
data: .,
126+
checks: {($checkName): $check}}
127+
128+
print-result: ${{ fromJSON(env.CI_DEBUG || 'false') && true || false }}
129+
- run: |
130+
# Cleanup temporary env file
131+
rm -rf ${{ runner.temp }}/${{ inputs.name }}.json
132+
shell: bash

actions/github/env/save/action.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
inputs:
2+
name:
3+
type: string
4+
default: env
5+
env:
6+
type: string
7+
required: true
8+
env-format:
9+
type: string
10+
env-filter:
11+
type: string
12+
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- id: path
18+
shell: bash
19+
run: |
20+
# Create temporary directory
21+
OUTPUT_DIR=$(mktemp -d)
22+
echo "directory=${OUTPUT_DIR}" >> $GITHUB_OUTPUT
23+
- uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d
24+
name: Check proxy data
25+
id: env
26+
with:
27+
input: |
28+
${{ inputs.env }}
29+
input-format: ${{ inputs.env-format }}
30+
filter: ${{ inputs.env-filter || '.' }}
31+
print-result: ${{ fromJSON(env.CI_DEBUG || 'false') && true || false }}
32+
output-path: ${{ steps.path.outputs.directory }}/${{ inputs.name }}.json
33+
34+
- name: Upload environment data
35+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
36+
with:
37+
name: ${{ inputs.name }}
38+
path: ${{ steps.path.outputs.directory }}
39+
40+
- name: Cleanup temporary directory
41+
shell: bash
42+
run: |
43+
# Cleanup temporary directory
44+
rm -rf ${{ steps.path.outputs.directory }}
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
inputs:
2+
actor:
3+
type: string
4+
required: true
5+
append:
6+
type: boolean
7+
default: true
8+
base-sha:
9+
type: string
10+
column-filter:
11+
type: string
12+
default:
13+
data:
14+
type: string
15+
required: true
16+
event-name:
17+
type: string
18+
default: Request
19+
event-type:
20+
type: string
21+
default:
22+
icon:
23+
type: string
24+
required: true
25+
indent:
26+
type: number
27+
default: 0
28+
link:
29+
type: string
30+
required: false
31+
message:
32+
type: string
33+
pr:
34+
type: number
35+
output-path:
36+
type: string
37+
ref:
38+
type: string
39+
sha:
40+
type: string
41+
required: true
42+
tables:
43+
type: string
44+
default:
45+
target-branch:
46+
type: string
47+
required: false
48+
title:
49+
type: string
50+
required: false
51+
52+
outputs:
53+
linked-title:
54+
value: ${{ steps.title.outputs.value }}
55+
summary:
56+
value: ${{ toJSON(steps.output.outputs.value) }}
57+
title:
58+
value: ${{ steps.title.outputs.value }}
59+
60+
61+
runs:
62+
using: composite
63+
steps:
64+
- uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d
65+
id: linked-title
66+
with:
67+
input: |
68+
event: "${{ inputs.event-type }}"
69+
link: ""
70+
repo: ${{ github.repository }}
71+
pr: "${{ inputs.pr }}"
72+
sha: ${{ inputs.sha }}
73+
target-branch: ${{ inputs.target-branch }}
74+
title: "${{ inputs.title }}"
75+
input-format: yaml
76+
options: -r
77+
filter: gfm::event_title
78+
79+
- uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d
80+
id: title
81+
with:
82+
input: |
83+
event: "${{ inputs.event-type }}"
84+
link: ${{ inputs.link }}
85+
repo: ${{ github.repository }}
86+
pr: "${{ inputs.pr }}"
87+
sha: ${{ inputs.sha }}
88+
target-branch: ${{ inputs.target-branch }}
89+
title: "${{ inputs.title }}"
90+
options: -r
91+
input-format: yaml
92+
filter: gfm::event_title
93+
94+
# This generates a filter from configuration
95+
- uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d
96+
name: Table filter
97+
id: table-filter
98+
with:
99+
input: ${{ inputs.tables }}
100+
input-format: yaml
101+
options: -r
102+
print-output: ${{ fromJSON(env.CI_DEBUG || 'false') && true || false }}
103+
filter: |
104+
with_entries({key: .key, value: .value.filter})
105+
| utils::filters
106+
- uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d
107+
name: Tables
108+
id: tables
109+
with:
110+
input: ${{ inputs.data }}
111+
options: -r
112+
filter: |
113+
. as $data
114+
| ${{ steps.table-filter.outputs.value }}
115+
| map(select(length > 0)) as $tableData
116+
| with_entries(select(.value | length > 0)) as $tableData
117+
| $data.config.tables
118+
| with_entries(
119+
del(.value.filter)
120+
| .value.data = $tableData[.key]
121+
| select(.value.data | type != "null"))
122+
| gfm::tables
123+
124+
- uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d
125+
id: output
126+
with:
127+
input: ${{ toJSON(inputs) }}
128+
options: -r
129+
filter: |
130+
. as $inputs
131+
| .sha as $sha
132+
| if $inputs.pr != "" then
133+
.["base-sha"] as $baseSha
134+
| "![](https://raw.githubusercontent.com/primer/octicons/main/icons/git-pull-request-16.svg)" as $prIcon
135+
| "[#\(.pr)](https://github.com/${{ github.repository }}/pull/\(.pr))" as $prLink
136+
| "[`merge`](https://github.com/${{ github.repository }}/commit/\(.ref))" as $mergeLink
137+
| "[`\(.["target-branch"])@\($baseSha[:7])`](https://github.com/${{ github.repository }}/commit/\($baseSha))" as $commitLink
138+
| "\($prIcon) \($prLink) \($mergeLink) \($commitLink)"
139+
else
140+
""
141+
end
142+
| . as $pr
143+
| "${{ steps.tables.outputs.value }}" as $tables
144+
| ${{ inputs.actor }} as $actor
145+
| "[`\($sha[:7])`](https://github.com/${{ github.repository }}/commit/\($sha))" as $commitLink
146+
| $inputs.message as $message
147+
| if $message != "" then
148+
($message | split("\n")[0]) as $title
149+
| ($message | "> " + (split("\n")[1:] | join("\n> "))) as $body
150+
| {title: $title, content: $body}
151+
| gfm::collapse
152+
else "" end
153+
| . as $change
154+
| "
155+
<img src=\"\($actor.icon)\" alt=\"\($actor.name)\" width=\"18\" height=\"18\"> @\($actor.name) \($commitLink) \($pr)
156+
157+
\($change)
158+
159+
\($tables)
160+
"
161+
| str::indent($inputs.indent // "0" | fromjson)
162+
163+
- uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d
164+
if: ${{ inputs.output-path }}
165+
with:
166+
input: ${{ steps.output.outputs.value }}
167+
options: -sRr
168+
output-path: ${{ inputs.output-path }}
169+
print-result: ${{ fromJSON(env.CI_DEBUG || 'false') && true || false }}
170+
filter: |
171+
. as $summary
172+
| "${{ inputs.icon }}" as $icon
173+
| "${{ steps.linked-title.outputs.value }}" as $link
174+
| "${{ inputs.event-name }}" as $event_name
175+
| "
176+
## \($icon) \($event_name) (\($link))
177+
178+
\($summary)
179+
"

0 commit comments

Comments
 (0)