[bitnami/*] ci: 👷 Allow updating changelog when using a fork (#26163)

* [bitnami/*] ci: 👷 Allow updating changelog when using a fork

Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>

* chore: 🔧 Do not specify repo

Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>

---------

Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>
This commit is contained in:
Javier J. Salmerón-García
2024-05-21 11:48:31 +02:00
committed by GitHub
parent e2584c81c1
commit 23e7379b5d

View File

@@ -105,6 +105,11 @@ jobs:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
token: ${{ secrets.BITNAMI_BOT_TOKEN }}
path: charts
- name: Clone upstream bitnami/charts repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
with:
path: upstream-charts
- name: Setup git configuration
run: |
git config user.name "Bitnami Containers"
@@ -114,8 +119,10 @@ jobs:
# regenerate the changelog too
- name: Unshallow main branch and get tags
run: |
cd ~/upstream-charts
git fetch origin main --unshallow
git fetch --tags
cd ..
- name: Install conventional-changelog-cli
run: npm install -g conventional-changelog-cli
- id: generate-changelog
@@ -123,12 +130,14 @@ jobs:
env:
CHART: ${{ needs.get-chart.outputs.chart }}
run: |
cd ~/upstream-charts
# The generator needs the file to exist
chart_version="$(yq e '.version' bitnami/${CHART}/Chart.yaml)"
changelog_file="bitnami/${CHART}/CHANGELOG.md"
changelog_tmp="bitnami/${CHART}/CHANGELOG.md.tmp"
chart_version="$(yq e '.version' ~/charts/bitnami/${CHART}/Chart.yaml)"
changelog_file="~/charts/bitnami/${CHART}/CHANGELOG.md"
changelog_tmp="~/charts/bitnami/${CHART}/CHANGELOG.md.tmp"
touch "$changelog_file"
npx conventional-changelog-cli -i ${changelog_file} -s -t ${CHART}/ -r 0 --commit-path bitnami/${CHART}
cd ~/charts
# Remove unreleased section (includes all intermediate commits in the branch) and create future entry based on PR title
# The unreleased section looks like this "## (YYYY-MM-DD)" whereas a released section looks like this "## 0.0.1 (YYYY-MM-DD)"
# So we only need to find a released section to start printing in the awk script below
@@ -154,6 +163,7 @@ jobs:
CHART: ${{ needs.get-chart.outputs.chart }}
run: |
exit_code=0
cd ~/charts
echo "Validating README.md for bitnami/${CHART}"
# Validating *.registry parameters
while read line; do
@@ -200,6 +210,7 @@ jobs:
CHART: ${{ needs.get-chart.outputs.chart }}
run: |
# Updating CRDs stored at 'bitnami/$CHART/crds' and 'bitnami/$CHART/templates/crds'
cd ~/charts
mapfile -t crd_files < <(find "bitnami/${CHART}/crds" "bitnami/${CHART}/templates/crds" -name "*.yaml" -o -name "*.yml" 2>/dev/null || true)
for file in "${crd_files[@]}"; do
# Automatically update CRDs that use the '# Source' header
@@ -280,6 +291,7 @@ jobs:
- id: update-pr
name: Push changes
run: |
cd ~/charts
# Push all the new commits, if any
if [[ $(git cherry -v) ]]; then
git push