From 592888bf36caaa599d36f69988c0c58ee9e021dd Mon Sep 17 00:00:00 2001 From: oscarbakker Date: Thu, 19 Dec 2024 15:31:49 +0100 Subject: [PATCH] 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