Skip to content

Commit 6e65977

Browse files
Add function and location.
1 parent 9b23e80 commit 6e65977

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

.github/workflows/bambda-checker-merge.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ jobs:
7171
run: |
7272
set -euo pipefail
7373
74+
to_sentence_case() {
75+
local str=$1
76+
echo "$str" | sed 's/_/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2))}1'
77+
}
78+
7479
extract_metadata() {
7580
local file=$1
7681
local field=$2
@@ -90,29 +95,41 @@ jobs:
9095
grep '@author' |
9196
sed 's/^[[:space:]]*\*[[:space:]]*@author[[:space:]]*//'
9297
;;
98+
function)
99+
local raw=$(grep '^function:' "$file" | head -1 | sed 's/^function: *//')
100+
to_sentence_case "$raw"
101+
;;
102+
location)
103+
local raw=$(grep '^location:' "$file" | head -1 | sed 's/^location: *//')
104+
to_sentence_case "$raw"
105+
;;
93106
esac
94107
}
95108
96109
build_payload() {
97110
local name=$1
98111
local description=$2
99112
local author=$3
100-
local url=$4
113+
local function=$4
114+
local location=$5
115+
local url=$6
101116
102117
jq -n \
103118
--arg name ":tada: $name" \
104119
--arg description "$description" \
105120
--arg author "$author" \
121+
--arg function "$function" \
122+
--arg location "$location" \
106123
--arg url "$url" \
107124
'{
108125
embeds: [{
109126
type: "rich",
110127
title: $name,
111128
description: (
112-
[
113-
$description,
114-
"**Author:** " + $author
115-
] | join("\n\n")
129+
$description + "\n\n" +
130+
"**Author:** " + $author + "\n" +
131+
"**Function:** " + $function + "\n" +
132+
"**Location:** " + $location
116133
),
117134
color: 2123412,
118135
url: $url
@@ -128,10 +145,12 @@ jobs:
128145
name=$(extract_metadata "$file" name)
129146
description=$(extract_metadata "$file" description)
130147
author=$(extract_metadata "$file" author)
148+
function=$(extract_metadata "$file" function)
149+
location=$(extract_metadata "$file" location)
131150
url="https://github.com/${GITHUB_REPOSITORY}/blob/main/$file"
132151
133152
safe_name=$(echo "$file" | sed 's/[^a-zA-Z0-9._-]/_/g')
134-
build_payload "$name" "$description" "$author" "$url" > "webhook_payloads/${safe_name}.json"
153+
build_payload "$name" "$description" "$author" "$function" "$location" "$url" > "webhook_payloads/${safe_name}.json"
135154
echo "$safe_name" >> webhook_payloads/file_list.txt
136155
done <<< "$BAMBDA_LIST"
137156

0 commit comments

Comments
 (0)