diff --git a/.gitea/workflows/update-images.yaml b/.gitea/workflows/update-images.yaml index c73667f..4e03e94 100644 --- a/.gitea/workflows/update-images.yaml +++ b/.gitea/workflows/update-images.yaml @@ -140,19 +140,51 @@ jobs: - name: Update Helm Repository Index if: steps.check_update.outputs.update_needed == 'true' run: | + set -e WP_VERSION="${{ steps.wordpress.outputs.wp_version }}" CHART_NAME=$(grep '^name:' Chart.yaml | awk '{print $2}') PACKAGE_FILE="${CHART_NAME}-${WP_VERSION}.tgz" - git fetch origin gh-pages || git checkout --orphan gh-pages - git checkout gh-pages || (git checkout --orphan gh-pages && git rm -rf .) - mv "${PACKAGE_FILE}" . - helm repo index . --url https://gitea.example.com/${GITHUB_REPOSITORY}/raw/branch/gh-pages + + echo "Preparing Helm repository update..." + + # パッケージファイルを一時ディレクトリに移動 + mkdir -p /tmp/helm-repo + cp "${PACKAGE_FILE}" /tmp/helm-repo/ + + # gh-pagesブランチの処理 + if git ls-remote --heads origin gh-pages | grep gh-pages; then + echo "gh-pages branch exists, checking out..." + git fetch origin gh-pages + git checkout gh-pages + else + echo "Creating new gh-pages branch..." + git checkout --orphan gh-pages + git rm -rf . || true + echo "# Helm Repository" > README.md + git add README.md + git config user.name "GitHub Actions Bot" + git config user.email "actions@github.com" + git commit -m "Initialize gh-pages branch" + git push origin gh-pages + fi + + # パッケージファイルをコピー + cp /tmp/helm-repo/"${PACKAGE_FILE}" . + + # index.yamlを生成/更新 + helm repo index . --url "https://gitea.example.com/${GITHUB_REPOSITORY}/raw/branch/gh-pages" + + # コミットしてプッシュ git config user.name "GitHub Actions Bot" git config user.email "actions@github.com" git add "${PACKAGE_FILE}" index.yaml - git commit -m "chore: add ${CHART_NAME} v${WP_VERSION}" + git commit -m "chore: add ${CHART_NAME} v${WP_VERSION}" || echo "No changes to commit" git push origin gh-pages - echo "Helm repository updated" + + echo "Helm repository updated successfully" + + # mainブランチに戻る + git checkout main - name: Summary if: steps.check_update.outputs.update_needed == 'true'