From 652e1890402ab19f628cb2f73f9f65c1c77d9d3f Mon Sep 17 00:00:00 2001 From: Lukas Jost Date: Thu, 18 Jul 2024 11:07:58 +0200 Subject: [PATCH 01/11] chore(repo): Add script to add ArtifactHub changelog annotations --- .github/workflows/update-mds.yml | 45 +++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-mds.yml b/.github/workflows/update-mds.yml index 9171fcf..d7c3286 100644 --- a/.github/workflows/update-mds.yml +++ b/.github/workflows/update-mds.yml @@ -37,11 +37,48 @@ jobs: echo "$chart: values.yaml changes detected" echo "Updating README.md for $chart" readme-generator --values "$chart/values.yaml" --readme "$chart/README.md" - # Check for changes and commit if necessary + done + - name: Update ArtifactHub change annotations + shell: bash + run: | + PR_TITLE="${{ github.event.pull_request.title }}" + add_changes_to_chart_yaml() { + local file_path="Chart.yaml" + local changes=$1 + if [ ! -f "$file_path" ]; then + echo "Chart.yaml not found!" + exit 1 + fi + chart=$(cat "$file_path") + # Check if annotations exist + if ! grep -q "annotations:" <<< "$chart"; then + chart=$(echo "$chart"$'\n'annotations:) + fi + # Check if artifacthub.io/changes annotation exists + if ! grep -q "artifacthub.io/changes:" <<< "$chart"; then + chart=$(echo "$chart"$'\n' artifacthub.io/changes: | sed 's/^/ /') + fi + # Append the new changes to the existing ones + chart=$(echo "$chart"$'\n'"$changes" | sed 's/^/ /') + echo "$chart" > "$file_path" + } + # Parse PR title to create changelog entries + changes="" + if [[ $PR_TITLE == *"feat:"* ]]; then + changes="$changes"$'\n' - kind: feature + changes="$changes"$'\n' description: "${PR_TITLE#*: }" + elif [[ $PR_TITLE == *"fix:"* ]]; then + changes="$changes"$'\n' - kind: bugfix + changes="$changes"$'\n' description: "${PR_TITLE#*: }" + fi + add_changes_to_chart_yaml "$changes" + - name: Commit and push changes + run: | + cd charts || exit 1 + for chart in */; do + # Check for changes and commit if necessary if git status -s | grep "$chart"; then git add "$chart" && git commit -m "docs(${chart%*/}): Update values in README.md" # Remove trailing slash + git push fi done - - name: Push changes - run: | - git push From 57d594a0fb34ef15b636364bbc6225fb1918c327 Mon Sep 17 00:00:00 2001 From: Lukas Jost Date: Thu, 18 Jul 2024 11:11:22 +0200 Subject: [PATCH 02/11] chore(repo): Simplify commit and push step --- .github/workflows/update-mds.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/update-mds.yml b/.github/workflows/update-mds.yml index d7c3286..c68f71c 100644 --- a/.github/workflows/update-mds.yml +++ b/.github/workflows/update-mds.yml @@ -74,11 +74,6 @@ jobs: add_changes_to_chart_yaml "$changes" - name: Commit and push changes run: | - cd charts || exit 1 - for chart in */; do - # Check for changes and commit if necessary - if git status -s | grep "$chart"; then - git add "$chart" && git commit -m "docs(${chart%*/}): Update values in README.md" # Remove trailing slash - git push - fi - done + git add . + git commit -m "docs(${chart%*/}): Update README.md, CHANGELOG.md and/or Chart.yaml" # Remove trailing slash + git push From c1478977d872b16d2e11e78fa507f0709baabb96 Mon Sep 17 00:00:00 2001 From: Lukas Jost Date: Thu, 18 Jul 2024 11:40:55 +0200 Subject: [PATCH 03/11] chore(repo): Generalise information gathering --- .github/workflows/update-mds.yml | 80 +++++++++++++++++++------------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/.github/workflows/update-mds.yml b/.github/workflows/update-mds.yml index c68f71c..c8f753d 100644 --- a/.github/workflows/update-mds.yml +++ b/.github/workflows/update-mds.yml @@ -22,46 +22,48 @@ jobs: run: | git config user.name "contane-bot" git config user.email "160241315+contane-bot@users.noreply.github.com" - - name: Install readme-generator-for-helm - run: npm install -g @bitnami/readme-generator-for-helm@2.6.1 - - name: Update README.md - shell: bash + - name: Gather pull request information run: | + NUM_CHANGED_CHARTS=0 cd charts || exit 1 for chart in */; do # Check if values.yaml has changed - if git diff --name-only HEAD~1 | grep -q "$chart/values.yaml"; then - echo "$chart: No values.yaml changes detected" + if git diff --name-only HEAD~1 | grep -q "$chart"; then + echo "$chart: Changes detected" continue fi - echo "$chart: values.yaml changes detected" - echo "Updating README.md for $chart" - readme-generator --values "$chart/values.yaml" --readme "$chart/README.md" + echo "$chart: Changes detected" + NUM_CHANGED_CHARTS=$((NUM_CHANGED_CHARTS + 1)) + echo "CHANGED_CHART=$chart" >> "$GITHUB_ENV" done + if [ "$NUM_CHANGED_CHARTS" -eq 0 ]; then + echo "No charts have changed" + exit 0 + fi + if [ "$NUM_CHANGED_CHARTS" -gt 1 ]; then + echo "Multiple charts have changed, only update one Chart per PR" + exit 1 + fi + if git diff --name-only HEAD~1 | grep -q "$CHANGED_CHART/values.yaml"; then + echo "$CHANGED_CHART: No values.yaml changes detected" + exit 0 + fi + echo "$CHANGED_CHART: values.yaml changes detected" + echo "VALUES_CHANGED=true" >> "$GITHUB_ENV" + - name: Install readme-generator-for-helm + if: env.VALUES_CHANGED == 'true' + run: npm install -g @bitnami/readme-generator-for-helm@2.6.1 + - name: Update README.md + if: env.VALUES_CHANGED == 'true' + shell: bash + run: | + cd charts || exit 1 + echo "Updating README.md for $CHANGED_CHART" + readme-generator --values "$CHANGED_CHART/values.yaml" --readme "$CHANGED_CHART/README.md" - name: Update ArtifactHub change annotations shell: bash run: | PR_TITLE="${{ github.event.pull_request.title }}" - add_changes_to_chart_yaml() { - local file_path="Chart.yaml" - local changes=$1 - if [ ! -f "$file_path" ]; then - echo "Chart.yaml not found!" - exit 1 - fi - chart=$(cat "$file_path") - # Check if annotations exist - if ! grep -q "annotations:" <<< "$chart"; then - chart=$(echo "$chart"$'\n'annotations:) - fi - # Check if artifacthub.io/changes annotation exists - if ! grep -q "artifacthub.io/changes:" <<< "$chart"; then - chart=$(echo "$chart"$'\n' artifacthub.io/changes: | sed 's/^/ /') - fi - # Append the new changes to the existing ones - chart=$(echo "$chart"$'\n'"$changes" | sed 's/^/ /') - echo "$chart" > "$file_path" - } # Parse PR title to create changelog entries changes="" if [[ $PR_TITLE == *"feat:"* ]]; then @@ -71,9 +73,25 @@ jobs: changes="$changes"$'\n' - kind: bugfix changes="$changes"$'\n' description: "${PR_TITLE#*: }" fi - add_changes_to_chart_yaml "$changes" + local file_path="Chart.yaml" + if [ ! -f "$file_path" ]; then + echo "Chart.yaml not found!" + exit 1 + fi + chart=$(cat "$file_path") + # Check if annotations exist + if ! grep -q "annotations:" <<< "$chart"; then + chart=$(echo "$chart"$'\n'annotations:) + fi + # Check if artifacthub.io/changes annotation exists + if ! grep -q "artifacthub.io/changes:" <<< "$chart"; then + chart=$(echo "$chart"$'\n' artifacthub.io/changes: | sed 's/^/ /') + fi + # Append the new changes to the existing ones + chart=$(echo "$chart"$'\n'"$changes" | sed 's/^/ /') + echo "$chart" > "$file_path" - name: Commit and push changes run: | git add . - git commit -m "docs(${chart%*/}): Update README.md, CHANGELOG.md and/or Chart.yaml" # Remove trailing slash + git commit -m "docs(${chart%*/}): Generate documentation" # Remove trailing slash git push From 8d625a5aac2d8ff613b06dfe37d40d53f5673c0a Mon Sep 17 00:00:00 2001 From: Lukas Jost Date: Thu, 18 Jul 2024 11:59:28 +0200 Subject: [PATCH 04/11] chore(repo): Split into two jobs --- .github/workflows/update-mds.yml | 57 ++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/.github/workflows/update-mds.yml b/.github/workflows/update-mds.yml index c8f753d..47e6900 100644 --- a/.github/workflows/update-mds.yml +++ b/.github/workflows/update-mds.yml @@ -6,10 +6,15 @@ on: - main jobs: - update-readme: + gather-information: runs-on: ubuntu-latest permissions: - contents: write + contents: read + pull-requests: read + outputs: + chart: ${{ steps.gather-information.outputs.chart }} + values_changed: ${{ steps.gather-information.outputs.values_changed }} + failed: ${{ steps.gather-information.outputs.failed }} steps: - name: Checkout uses: actions/checkout@v4 @@ -18,18 +23,15 @@ jobs: ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} token: ${{secrets.CONTANE_BOT_TOKEN}} - - name: Configure Git - run: | - git config user.name "contane-bot" - git config user.email "160241315+contane-bot@users.noreply.github.com" - name: Gather pull request information + id: gather-information run: | NUM_CHANGED_CHARTS=0 cd charts || exit 1 for chart in */; do # Check if values.yaml has changed if git diff --name-only HEAD~1 | grep -q "$chart"; then - echo "$chart: Changes detected" + echo "$chart: No changes detected" continue fi echo "$chart: Changes detected" @@ -37,24 +39,51 @@ jobs: echo "CHANGED_CHART=$chart" >> "$GITHUB_ENV" done if [ "$NUM_CHANGED_CHARTS" -eq 0 ]; then - echo "No charts have changed" - exit 0 + echo "ERROR=No charts have changed" >> "$GITHUB_ENV" + echo "FAILED=true" >> "$GITHUB_ENV fi if [ "$NUM_CHANGED_CHARTS" -gt 1 ]; then - echo "Multiple charts have changed, only update one Chart per PR" - exit 1 + echo "ERROR=Multiple charts have changed, only update one Chart per PR" >> "$GITHUB_ENV" + echo "FAILED=true" >> "$GITHUB_ENV fi if git diff --name-only HEAD~1 | grep -q "$CHANGED_CHART/values.yaml"; then echo "$CHANGED_CHART: No values.yaml changes detected" - exit 0 fi echo "$CHANGED_CHART: values.yaml changes detected" echo "VALUES_CHANGED=true" >> "$GITHUB_ENV" + # Using actions/github-scripts because using exit 1 in the script above would not provide any output + # Source: https://github.community/t/no-output-on-process-completed-with-exit-code-1/123821/3 + - id: show-error + name: Show error + if: ${{ steps.gather-inforation.outputs.failed }} + uses: actions/github-script@7.0.1 + with: + script: | + if (!${{ steps.gather-inforation.outputs.error }}) { + core.setFailed(${{ steps.gather-inforation.outputs.error }}); + } + update-documentation: + runs-on: ubuntu-latest + permissions: + contents: write + if: ${{ needs.gather-information.outputs.failed != 'true' }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + token: ${{ secrets.CONTANE_BOT_TOKEN }} + - name: Configure Git + run: | + git config user.name "contane-bot" + git config user.email "160241315+contane-bot@users.noreply.github.com" - name: Install readme-generator-for-helm - if: env.VALUES_CHANGED == 'true' + if: ${{ needs.gather-information.outputs.values_changed == 'true' }} run: npm install -g @bitnami/readme-generator-for-helm@2.6.1 - name: Update README.md - if: env.VALUES_CHANGED == 'true' + if: ${{ needs.gather-information.outputs.values_changed == 'true' }} shell: bash run: | cd charts || exit 1 From 443246a84863dbd20b94f20664788620a33ced2b Mon Sep 17 00:00:00 2001 From: Lukas Jost Date: Fri, 19 Jul 2024 13:13:46 +0200 Subject: [PATCH 05/11] chore(repo): Add generation of CHANGELOG.md --- .github/workflows/update-mds.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/update-mds.yml b/.github/workflows/update-mds.yml index 47e6900..4f25836 100644 --- a/.github/workflows/update-mds.yml +++ b/.github/workflows/update-mds.yml @@ -89,6 +89,16 @@ jobs: cd charts || exit 1 echo "Updating README.md for $CHANGED_CHART" readme-generator --values "$CHANGED_CHART/values.yaml" --readme "$CHANGED_CHART/README.md" + - name: Update changelog.md + shell: bash + run: | + echo "Generating changelog for $CHANGED_CHART" + npx semantic-release --dry-run --no-ci --plugins @semantic-release/release-notes-generator > $CHANGED_CHART/release-notes.md + # Extract relevant part + sed -n '/### \[/{:a;n;/### \[/{p;q};p;ba}' $CHANGED_CHART/release-notes.md > $CHANGED_CHART/CHANGELOG.md + rm $CHANGED_CHART/release-notes.md + - name: Install changelog-generator + run: npm install -g github-changelog-generator - name: Update ArtifactHub change annotations shell: bash run: | From da0f41b2db4515582f591819e2bf186341f7e932 Mon Sep 17 00:00:00 2001 From: Lukas Jost Date: Fri, 19 Jul 2024 13:15:26 +0200 Subject: [PATCH 06/11] chore(repo): Rename workflow to fit new functions --- .github/workflows/{update-mds.yml => update-documentation.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{update-mds.yml => update-documentation.yml} (99%) diff --git a/.github/workflows/update-mds.yml b/.github/workflows/update-documentation.yml similarity index 99% rename from .github/workflows/update-mds.yml rename to .github/workflows/update-documentation.yml index 4f25836..28af044 100644 --- a/.github/workflows/update-mds.yml +++ b/.github/workflows/update-documentation.yml @@ -1,4 +1,4 @@ -name: Update README.md +name: Update documentation on: pull_request_target: From 1a5890c2d42309d2b921928bd2baa95808d8dfdb Mon Sep 17 00:00:00 2001 From: Lukas Jost Date: Fri, 19 Jul 2024 14:09:00 +0200 Subject: [PATCH 07/11] chore(repo): Apply suggestions from code review Co-authored-by: Fabian Meyer <3982806+meyfa@users.noreply.github.com> --- .github/workflows/update-documentation.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update-documentation.yml b/.github/workflows/update-documentation.yml index 28af044..068764a 100644 --- a/.github/workflows/update-documentation.yml +++ b/.github/workflows/update-documentation.yml @@ -20,11 +20,12 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - token: ${{secrets.CONTANE_BOT_TOKEN}} + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + token: ${{ secrets.CONTANE_BOT_TOKEN }} - name: Gather pull request information id: gather-information + shell: bash run: | NUM_CHANGED_CHARTS=0 cd charts || exit 1 @@ -55,17 +56,18 @@ jobs: # Source: https://github.community/t/no-output-on-process-completed-with-exit-code-1/123821/3 - id: show-error name: Show error - if: ${{ steps.gather-inforation.outputs.failed }} + if: ${{ steps.gather-information.outputs.failed }} uses: actions/github-script@7.0.1 with: script: | - if (!${{ steps.gather-inforation.outputs.error }}) { - core.setFailed(${{ steps.gather-inforation.outputs.error }}); + if (!${{ steps.gather-information.outputs.error }}) { + core.setFailed(${{ steps.gather-information.outputs.error }}); } update-documentation: runs-on: ubuntu-latest permissions: contents: write + needs: gather-information if: ${{ needs.gather-information.outputs.failed != 'true' }} steps: - name: Checkout From 8236211128056f54101685f250eeba95d062f26a Mon Sep 17 00:00:00 2001 From: Lukas Jost Date: Mon, 22 Jul 2024 21:22:59 +0200 Subject: [PATCH 08/11] chore(repo): Use exit 1 instead of variables and an extra job --- .github/workflows/update-documentation.yml | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/update-documentation.yml b/.github/workflows/update-documentation.yml index 068764a..6d9af35 100644 --- a/.github/workflows/update-documentation.yml +++ b/.github/workflows/update-documentation.yml @@ -23,6 +23,7 @@ jobs: ref: ${{ github.event.pull_request.head.ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} token: ${{ secrets.CONTANE_BOT_TOKEN }} + - name: Gather pull request information id: gather-information shell: bash @@ -40,35 +41,27 @@ jobs: echo "CHANGED_CHART=$chart" >> "$GITHUB_ENV" done if [ "$NUM_CHANGED_CHARTS" -eq 0 ]; then - echo "ERROR=No charts have changed" >> "$GITHUB_ENV" - echo "FAILED=true" >> "$GITHUB_ENV + echo "No charts have changed" + exit 1 fi if [ "$NUM_CHANGED_CHARTS" -gt 1 ]; then - echo "ERROR=Multiple charts have changed, only update one Chart per PR" >> "$GITHUB_ENV" - echo "FAILED=true" >> "$GITHUB_ENV + echo "Multiple charts have changed, only update one Chart per PR" + exit 1 fi if git diff --name-only HEAD~1 | grep -q "$CHANGED_CHART/values.yaml"; then echo "$CHANGED_CHART: No values.yaml changes detected" fi echo "$CHANGED_CHART: values.yaml changes detected" echo "VALUES_CHANGED=true" >> "$GITHUB_ENV" - # Using actions/github-scripts because using exit 1 in the script above would not provide any output - # Source: https://github.community/t/no-output-on-process-completed-with-exit-code-1/123821/3 - - id: show-error - name: Show error - if: ${{ steps.gather-information.outputs.failed }} - uses: actions/github-script@7.0.1 - with: - script: | - if (!${{ steps.gather-information.outputs.error }}) { - core.setFailed(${{ steps.gather-information.outputs.error }}); - } + update-documentation: runs-on: ubuntu-latest permissions: contents: write needs: gather-information if: ${{ needs.gather-information.outputs.failed != 'true' }} + env: + PR_TITLE: ${{ github.event.pull_request.title }} steps: - name: Checkout uses: actions/checkout@v4 @@ -77,13 +70,16 @@ jobs: ref: ${{ github.event.pull_request.head.ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} token: ${{ secrets.CONTANE_BOT_TOKEN }} + - name: Configure Git run: | git config user.name "contane-bot" git config user.email "160241315+contane-bot@users.noreply.github.com" + - name: Install readme-generator-for-helm if: ${{ needs.gather-information.outputs.values_changed == 'true' }} run: npm install -g @bitnami/readme-generator-for-helm@2.6.1 + - name: Update README.md if: ${{ needs.gather-information.outputs.values_changed == 'true' }} shell: bash @@ -91,6 +87,7 @@ jobs: cd charts || exit 1 echo "Updating README.md for $CHANGED_CHART" readme-generator --values "$CHANGED_CHART/values.yaml" --readme "$CHANGED_CHART/README.md" + - name: Update changelog.md shell: bash run: | @@ -99,12 +96,13 @@ jobs: # Extract relevant part sed -n '/### \[/{:a;n;/### \[/{p;q};p;ba}' $CHANGED_CHART/release-notes.md > $CHANGED_CHART/CHANGELOG.md rm $CHANGED_CHART/release-notes.md + - name: Install changelog-generator run: npm install -g github-changelog-generator + - name: Update ArtifactHub change annotations shell: bash run: | - PR_TITLE="${{ github.event.pull_request.title }}" # Parse PR title to create changelog entries changes="" if [[ $PR_TITLE == *"feat:"* ]]; then @@ -131,6 +129,7 @@ jobs: # Append the new changes to the existing ones chart=$(echo "$chart"$'\n'"$changes" | sed 's/^/ /') echo "$chart" > "$file_path" + - name: Commit and push changes run: | git add . From d0315fabbc7a8e42ad9cf6cd1bb5095ecc54ca0b Mon Sep 17 00:00:00 2001 From: Lukas Jost Date: Mon, 22 Jul 2024 21:24:07 +0200 Subject: [PATCH 09/11] chore(repo): Use $CHANGED_CHART instead of chart variable --- .github/workflows/update-documentation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-documentation.yml b/.github/workflows/update-documentation.yml index 6d9af35..86e3d86 100644 --- a/.github/workflows/update-documentation.yml +++ b/.github/workflows/update-documentation.yml @@ -133,5 +133,5 @@ jobs: - name: Commit and push changes run: | git add . - git commit -m "docs(${chart%*/}): Generate documentation" # Remove trailing slash + git commit -m "docs(${CHANGED_CHART%*/}): Generate documentation" # Remove trailing slash git push From c4d6e05a034a7c9d1fcf430463bbde679337c79a Mon Sep 17 00:00:00 2001 From: Lukas Jost Date: Mon, 22 Jul 2024 21:29:15 +0200 Subject: [PATCH 10/11] chore(repo): Quote variable to avoid shell injection --- .github/workflows/update-documentation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-documentation.yml b/.github/workflows/update-documentation.yml index 86e3d86..b22368e 100644 --- a/.github/workflows/update-documentation.yml +++ b/.github/workflows/update-documentation.yml @@ -38,7 +38,7 @@ jobs: fi echo "$chart: Changes detected" NUM_CHANGED_CHARTS=$((NUM_CHANGED_CHARTS + 1)) - echo "CHANGED_CHART=$chart" >> "$GITHUB_ENV" + echo "CHANGED_CHART=\"$chart\"" >> "$GITHUB_ENV" done if [ "$NUM_CHANGED_CHARTS" -eq 0 ]; then echo "No charts have changed" From 3bd45624d16ef8f958a53aa0074e649859b55de2 Mon Sep 17 00:00:00 2001 From: Lukas Jost Date: Tue, 23 Jul 2024 16:11:15 +0200 Subject: [PATCH 11/11] chore(repo): Add suggestions --- .github/workflows/update-documentation.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/update-documentation.yml b/.github/workflows/update-documentation.yml index b22368e..6b3a6db 100644 --- a/.github/workflows/update-documentation.yml +++ b/.github/workflows/update-documentation.yml @@ -4,6 +4,8 @@ on: pull_request_target: branches: - main + paths: + - "charts/**" jobs: gather-information: @@ -31,7 +33,7 @@ jobs: NUM_CHANGED_CHARTS=0 cd charts || exit 1 for chart in */; do - # Check if values.yaml has changed + # Check if there are changes if git diff --name-only HEAD~1 | grep -q "$chart"; then echo "$chart: No changes detected" continue @@ -40,12 +42,8 @@ jobs: NUM_CHANGED_CHARTS=$((NUM_CHANGED_CHARTS + 1)) echo "CHANGED_CHART=\"$chart\"" >> "$GITHUB_ENV" done - if [ "$NUM_CHANGED_CHARTS" -eq 0 ]; then - echo "No charts have changed" - exit 1 - fi if [ "$NUM_CHANGED_CHARTS" -gt 1 ]; then - echo "Multiple charts have changed, only update one Chart per PR" + echo "Multiple charts have changed, only update one chart per PR" exit 1 fi if git diff --name-only HEAD~1 | grep -q "$CHANGED_CHART/values.yaml"; then @@ -92,10 +90,10 @@ jobs: shell: bash run: | echo "Generating changelog for $CHANGED_CHART" - npx semantic-release --dry-run --no-ci --plugins @semantic-release/release-notes-generator > $CHANGED_CHART/release-notes.md + npx semantic-release --dry-run --no-ci --plugins @semantic-release/release-notes-generator > "$CHANGED_CHART/release-notes.md" # Extract relevant part - sed -n '/### \[/{:a;n;/### \[/{p;q};p;ba}' $CHANGED_CHART/release-notes.md > $CHANGED_CHART/CHANGELOG.md - rm $CHANGED_CHART/release-notes.md + sed -n '/### \[/{:a;n;/### \[/{p;q};p;ba}' "$CHANGED_CHART/release-notes.md" > "$CHANGED_CHART/CHANGELOG.md" + rm "$CHANGED_CHART/release-notes.md" - name: Install changelog-generator run: npm install -g github-changelog-generator @@ -108,7 +106,7 @@ jobs: if [[ $PR_TITLE == *"feat:"* ]]; then changes="$changes"$'\n' - kind: feature changes="$changes"$'\n' description: "${PR_TITLE#*: }" - elif [[ $PR_TITLE == *"fix:"* ]]; then + elif [[ "$PR_TITLE" == *"fix:"* ]]; then changes="$changes"$'\n' - kind: bugfix changes="$changes"$'\n' description: "${PR_TITLE#*: }" fi