-
Notifications
You must be signed in to change notification settings - Fork 191
84 lines (71 loc) · 2.55 KB
/
Copy pathsend-discord-message.yml
File metadata and controls
84 lines (71 loc) · 2.55 KB
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
name: Send discord notification
on:
workflow_dispatch:
inputs:
filename:
description: "Filename"
type: string
required: true
status:
description: "Status"
type: string
required: true
permissions:
contents: read
actions: write
defaults:
run:
shell: bash
jobs:
StatusChangeNotifications:
runs-on: hiero-improvement-proposals-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Extract HIP abstract
id: extract_abstract
env:
FILENAME: ${{ github.event.inputs.filename }}
run: |
# Add .md extension if not present
if [[ "$FILENAME" == *.md ]]; then
HIP_FILE="HIP/${FILENAME}"
else
HIP_FILE="HIP/${FILENAME}.md"
fi
# Verify file exists
if [ ! -f "$HIP_FILE" ]; then
echo "Error: File $HIP_FILE does not exist"
echo "abstract=File not found: $HIP_FILE" >> "$GITHUB_OUTPUT"
exit 0
fi
# Extract the abstract section (text between "## Abstract" and the next "##" heading)
ABSTRACT=$(sed -n '/^## Abstract$/,/^## /p' "$HIP_FILE" | sed '$d' | tail -n +2 | sed '/^$/d')
# If abstract is empty, use a default message
if [ -z "$ABSTRACT" ]; then
ABSTRACT="No abstract available for this HIP."
fi
# Save the abstract to output (escape for GitHub Actions)
{
echo "abstract<<EOF"
echo "$ABSTRACT"
echo "EOF"
} >> "$GITHUB_OUTPUT"
# Save the filename without extension for URL
FILENAME_NO_EXT="${FILENAME%.md}"
echo "filename_no_ext=$FILENAME_NO_EXT" >> "$GITHUB_OUTPUT"
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD }}
uses: step-security/action-discord@e31fd4e664027caad89e85cc4e9166e193dd6d2d # v0.1.5
with:
args: |
# ${{ steps.extract_abstract.outputs.filename_no_ext }} moved into ${{ github.event.inputs.status }} status
## About this HIP
${{ steps.extract_abstract.outputs.abstract }}
Read the full HIP here:
https://hips.hedera.com/hip/${{ steps.extract_abstract.outputs.filename_no_ext }}