Skip to content

Commit 7e48a15

Browse files
committed
Fix discord notification workflow filename handling
- Automatically append .md extension if not present in filename input - Add file existence check with graceful error handling - Extract filename without extension for URL generation - Handle both hip-1299 and hip-1299.md input formats Signed-off-by: Michael Garber <michael.garber@hashgraph.com>
1 parent 99bf630 commit 7e48a15

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

.github/workflows/send-discord-message.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,19 @@ jobs:
3636
env:
3737
FILENAME: ${{ github.event.inputs.filename }}
3838
run: |
39-
HIP_FILE="HIP/${FILENAME}"
39+
# Add .md extension if not present
40+
if [[ "$FILENAME" == *.md ]]; then
41+
HIP_FILE="HIP/${FILENAME}"
42+
else
43+
HIP_FILE="HIP/${FILENAME}.md"
44+
fi
45+
46+
# Verify file exists
47+
if [ ! -f "$HIP_FILE" ]; then
48+
echo "Error: File $HIP_FILE does not exist"
49+
echo "abstract=File not found: $HIP_FILE" >> "$GITHUB_OUTPUT"
50+
exit 0
51+
fi
4052
4153
# Extract the abstract section (text between "## Abstract" and the next "##" heading)
4254
ABSTRACT=$(sed -n '/^## Abstract$/,/^## /p' "$HIP_FILE" | sed '$d' | tail -n +2 | sed '/^$/d')
@@ -53,16 +65,20 @@ jobs:
5365
echo "EOF"
5466
} >> "$GITHUB_OUTPUT"
5567
68+
# Save the filename without extension for URL
69+
FILENAME_NO_EXT="${FILENAME%.md}"
70+
echo "filename_no_ext=$FILENAME_NO_EXT" >> "$GITHUB_OUTPUT"
71+
5672
- name: Discord notification
5773
env:
5874
DISCORD_WEBHOOK: ${{ secrets.DISCORD }}
5975
uses: step-security/action-discord@25f3b8e2229f3a238679abdbcf82d84a075419bd # v0.1.3
6076
with:
6177
args: |
62-
# ${{ github.event.inputs.filename }} moved into ${{ github.event.inputs.status }} status
78+
# ${{ steps.extract_abstract.outputs.filename_no_ext }} moved into ${{ github.event.inputs.status }} status
6379
6480
## About this HIP
6581
${{ steps.extract_abstract.outputs.abstract }}
6682
6783
Read the full HIP here:
68-
https://hips.hedera.com/hip/${{ github.event.inputs.filename }}
84+
https://hips.hedera.com/hip/${{ steps.extract_abstract.outputs.filename_no_ext }}

0 commit comments

Comments
 (0)