From f8923e3d7aa418d3ecceeb3722aa7ddea22027de Mon Sep 17 00:00:00 2001 From: oscarbakker Date: Thu, 19 Dec 2024 15:31:49 +0100 Subject: [PATCH 1/2] Conditionally set note headers --- .github/workflows/pr-title-check.yml | 7 +++-- .github/workflows/release-notification.yml | 35 ++++++++++++++-------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr-title-check.yml b/.github/workflows/pr-title-check.yml index 55a9b7f2e4..0cfb3babaa 100644 --- a/.github/workflows/pr-title-check.yml +++ b/.github/workflows/pr-title-check.yml @@ -18,10 +18,13 @@ jobs: // Titel moet beginnen met mijn-xxxx-chore/feature/bug! todo mijn- patroon moet weggehaald worden wanneer de workflows van mijn-7620 gemerged zijn const jiraPattern = /^MIJN-\d+-(CHORE|FEATURE|BUG)/i const dependabotPattern = /^Build\(deps(-dev)?\): bump/ + const disallowedQuotesPattern = /"/ - if (!(jiraPattern.test(prTitle) || dependabotPattern.test(prTitle))) { + if (disallowedQuotesPattern.test(prTitle)) { + console.log('The PR title contains double quotes, which are not allowed!') + core.setFailed('PR title not valid. Please remove double quotes from the title.') + } else if (!(jiraPattern.test(prTitle) || dependabotPattern.test(prTitle))) { console.log('The PR title does not match JIRA ticket format!') - // Fails the workflow core.setFailed('PR title not valid. Please make sure this PR uses the JIRA ticket or dependabot format.') } else { console.log('PR title format is correct.') diff --git a/.github/workflows/release-notification.yml b/.github/workflows/release-notification.yml index e115633916..9edd5ba555 100644 --- a/.github/workflows/release-notification.yml +++ b/.github/workflows/release-notification.yml @@ -59,22 +59,31 @@ jobs: grep -iE 'BUG:|MIJN-[0-9]+-BUG' release_notes.txt > bugs.txt || true grep -iE 'MIJN-[0-9]+($|[^-])' release_notes.txt > mijn.txt || true - echo "chores<> $GITHUB_OUTPUT - cat chores.txt >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + - name: Output Categorized Notes + run: | + if [ -s chores.txt ]; then + echo "chores<> $GITHUB_OUTPUT + cat chores.txt >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + fi - echo "features<> $GITHUB_OUTPUT - cat features.txt >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + if [ -s features.txt ]; then + echo "features<> $GITHUB_OUTPUT + cat features.txt >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + fi - echo "bugs<> $GITHUB_OUTPUT - cat bugs.txt >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + if [ -s bugs.txt ]; then + echo "bugs<> $GITHUB_OUTPUT + cat bugs.txt >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + fi - echo "mijn<> $GITHUB_OUTPUT - cat mijn.txt >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - shell: bash + if [ -s mijn.txt ]; then + echo "mijn<> $GITHUB_OUTPUT + cat mijn.txt >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + fi - name: Create Customized Release Notes id: custom_release_notes From e0c3bb106626930845c93b8a320063e679170eb4 Mon Sep 17 00:00:00 2001 From: Roan Paulus Date: Tue, 7 Jan 2025 10:36:10 +0100 Subject: [PATCH 2/2] extracted repeated code into function --- .github/workflows/release-notification.yml | 34 +++++++--------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release-notification.yml b/.github/workflows/release-notification.yml index 9edd5ba555..da7978c9bd 100644 --- a/.github/workflows/release-notification.yml +++ b/.github/workflows/release-notification.yml @@ -61,29 +61,17 @@ jobs: - name: Output Categorized Notes run: | - if [ -s chores.txt ]; then - echo "chores<> $GITHUB_OUTPUT - cat chores.txt >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - fi - - if [ -s features.txt ]; then - echo "features<> $GITHUB_OUTPUT - cat features.txt >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - fi - - if [ -s bugs.txt ]; then - echo "bugs<> $GITHUB_OUTPUT - cat bugs.txt >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - fi - - if [ -s mijn.txt ]; then - echo "mijn<> $GITHUB_OUTPUT - cat mijn.txt >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - fi + append_to_github_output() { + if [ -s "$1.txt" ]; then + echo "$1<> "$GITHUB_OUTPUT" + cat "$1.txt" >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + fi + } + append_to_github_output 'chores' + append_to_github_output 'features' + append_to_github_output 'bugs' + append_to_github_output 'mijn' - name: Create Customized Release Notes id: custom_release_notes