From f721b61325ebbeec73c3a4f217e4381da48947b6 Mon Sep 17 00:00:00 2001 From: peterkogo Date: Wed, 30 Oct 2024 13:12:48 +0100 Subject: [PATCH] simplified message formating --- .github/workflows/createWhatsNew.yaml | 18 ++---------------- .github/workflows/scripts/formatRelease.js | 15 +++++++++++++++ .github/workflows/scripts/postToDiscord.js | 1 + 3 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/scripts/formatRelease.js diff --git a/.github/workflows/createWhatsNew.yaml b/.github/workflows/createWhatsNew.yaml index c0c73501e..0de6cb2e3 100644 --- a/.github/workflows/createWhatsNew.yaml +++ b/.github/workflows/createWhatsNew.yaml @@ -35,25 +35,11 @@ jobs: git config --global user.name 'github-actions[bot]' - name: 'Create branch' run: git checkout -b ${{ env.BRANCH }} - - name: 'Remove Thanks' + - name: 'Format Release Message' run: | { echo 'CLEAN_BODY<> "$GITHUB_ENV" - - name: 'Remove Commits' - run: | - { - echo 'CLEAN_BODY<> "$GITHUB_ENV" - - name: 'Remove Updated Dependencies' - run: | - { - echo 'CLEAN_BODY<> "$GITHUB_ENV" - name: 'Post to Discord' diff --git a/.github/workflows/scripts/formatRelease.js b/.github/workflows/scripts/formatRelease.js new file mode 100644 index 000000000..6a4c9b52a --- /dev/null +++ b/.github/workflows/scripts/formatRelease.js @@ -0,0 +1,15 @@ +const removeThanks = + /Thanks \[@(?:moklick|peterkogo|hayleigh-dot-dev|chrtze|bcakmakoglu)\]\(.*\)! \- */g; +const removeCommits = /(\[.*\]\(.*\)) (\[.*\]\(.*\)) /g; +const removeDeps = /- *Updated dependencies.*/gs; +const removeNewlines = /\n\n/g; + +(async () => { + const body = process.env.BODY; + let newBody = body + .replaceAll(removeThanks, '') + .replaceAll(removeCommits, '$1 ') + .replaceAll(removeDeps, '') + .replaceAll(removeNewlines, '\n'); + console.log(newBody); +})(); diff --git a/.github/workflows/scripts/postToDiscord.js b/.github/workflows/scripts/postToDiscord.js index 2988930af..c15834287 100644 --- a/.github/workflows/scripts/postToDiscord.js +++ b/.github/workflows/scripts/postToDiscord.js @@ -2,6 +2,7 @@ const content = `Hey [INSERT MENTION HERE], **${process.env.FRAMEWORK} Flow ${process.env.VERSION}** is out! + ${process.env.CLEAN_BODY} `;