fix: Improve workflow - PHP-only releases and error handling
All checks were successful
Helm Chart Release / release-chart (push) Successful in 12s
All checks were successful
Helm Chart Release / release-chart (push) Successful in 12s
更新がない場合やバージョン抽出失敗時のエラーを解消。 PHPバージョンアップ時のみリリース、Nginx/Seleniumのみの場合はvalues.yaml更新のみ。 Changes: - PHPバージョン抽出失敗時は警告のみ(exit 1を削除) - 更新判定ロジックを改善(php_updated フラグを追加) - Chart.yaml更新とリリース処理をPHP更新時のみに限定 - Nginx/Seleniumのみ更新時はvalues.yamlのみコミット - 既存タグ/リリースのチェックを追加(重複エラー回避) - コミットメッセージを更新内容に応じて変更 - Summaryにリリース有無の情報を追加 Behavior: - PHP更新時: values.yaml + Chart.yaml更新、リリース作成 - Nginx/Selenium更新時: values.yamlのみ更新、リリースなし - 更新なし: 正常終了(エラーなし) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -72,8 +72,9 @@ jobs:
|
|||||||
# PHPバージョンを抽出 (8.5.2の部分)
|
# PHPバージョンを抽出 (8.5.2の部分)
|
||||||
APP_VERSION=$(echo "$LATEST" | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+')
|
APP_VERSION=$(echo "$LATEST" | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+')
|
||||||
if [ -z "$APP_VERSION" ]; then
|
if [ -z "$APP_VERSION" ]; then
|
||||||
echo "Error: Could not extract PHP version from: $LATEST"
|
echo "Warning: Could not extract PHP version from: $LATEST"
|
||||||
exit 1
|
echo "Using current version instead"
|
||||||
|
APP_VERSION=$(echo "$CURRENT" | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Latest PHP: $LATEST"
|
echo "Latest PHP: $LATEST"
|
||||||
@@ -120,12 +121,33 @@ jobs:
|
|||||||
echo "PHP: $PHP_CURRENT vs $PHP_LATEST"
|
echo "PHP: $PHP_CURRENT vs $PHP_LATEST"
|
||||||
echo "Selenium: $SELENIUM_CURRENT vs $SELENIUM_LATEST"
|
echo "Selenium: $SELENIUM_CURRENT vs $SELENIUM_LATEST"
|
||||||
|
|
||||||
if [ "$NGINX_CURRENT" != "$NGINX_LATEST" ] || [ "$PHP_CURRENT" != "$PHP_LATEST" ] || [ "$SELENIUM_CURRENT" != "$SELENIUM_LATEST" ]; then
|
# 更新が必要かチェック
|
||||||
echo "update_needed=true" >> $GITHUB_OUTPUT
|
UPDATE_NEEDED=false
|
||||||
|
PHP_UPDATED=false
|
||||||
|
|
||||||
|
if [ "$PHP_CURRENT" != "$PHP_LATEST" ]; then
|
||||||
|
UPDATE_NEEDED=true
|
||||||
|
PHP_UPDATED=true
|
||||||
|
echo "PHP update detected"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$NGINX_CURRENT" != "$NGINX_LATEST" ]; then
|
||||||
|
UPDATE_NEEDED=true
|
||||||
|
echo "Nginx update detected"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SELENIUM_CURRENT" != "$SELENIUM_LATEST" ]; then
|
||||||
|
UPDATE_NEEDED=true
|
||||||
|
echo "Selenium update detected"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "update_needed=$UPDATE_NEEDED" >> $GITHUB_OUTPUT
|
||||||
|
echo "php_updated=$PHP_UPDATED" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
if [ "$UPDATE_NEEDED" = "true" ]; then
|
||||||
echo "Update is needed"
|
echo "Update is needed"
|
||||||
else
|
else
|
||||||
echo "update_needed=false" >> $GITHUB_OUTPUT
|
echo "Already up to date - no action required"
|
||||||
echo "Already up to date"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Update values.yaml
|
- name: Update values.yaml
|
||||||
@@ -169,7 +191,7 @@ jobs:
|
|||||||
git diff values.yaml
|
git diff values.yaml
|
||||||
|
|
||||||
- name: Update Chart.yaml version
|
- name: Update Chart.yaml version
|
||||||
if: steps.check_update.outputs.update_needed == 'true'
|
if: steps.check_update.outputs.php_updated == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
APP_VERSION="${{ steps.php.outputs.app_version }}"
|
APP_VERSION="${{ steps.php.outputs.app_version }}"
|
||||||
@@ -183,26 +205,41 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git config user.name "GitHub Actions Bot"
|
git config user.name "GitHub Actions Bot"
|
||||||
git config user.email "actions@github.com"
|
git config user.email "actions@github.com"
|
||||||
|
|
||||||
|
if [ "${{ steps.check_update.outputs.php_updated }}" = "true" ]; then
|
||||||
|
# PHP更新時はChart.yamlも含める
|
||||||
git add values.yaml Chart.yaml
|
git add values.yaml Chart.yaml
|
||||||
git commit -m "chore: update to PHP ${{ steps.php.outputs.app_version }}, nginx ${{ steps.nginx.outputs.latest }}, selenium ${{ steps.selenium.outputs.latest }}"
|
git commit -m "chore: update to PHP ${{ steps.php.outputs.app_version }}, nginx ${{ steps.nginx.outputs.latest }}, selenium ${{ steps.selenium.outputs.latest }}"
|
||||||
|
else
|
||||||
|
# Nginx/Seleniumのみの更新時はvalues.yamlのみ
|
||||||
|
git add values.yaml
|
||||||
|
git commit -m "chore: update nginx to ${{ steps.nginx.outputs.latest }}, selenium to ${{ steps.selenium.outputs.latest }} (no release)"
|
||||||
|
fi
|
||||||
|
|
||||||
git push origin main
|
git push origin main
|
||||||
|
|
||||||
- name: Package Helm Chart
|
- name: Package Helm Chart
|
||||||
if: steps.check_update.outputs.update_needed == 'true'
|
if: steps.check_update.outputs.php_updated == 'true'
|
||||||
run: |
|
run: |
|
||||||
helm package .
|
helm package .
|
||||||
echo "Helm chart packaged"
|
echo "Helm chart packaged"
|
||||||
|
|
||||||
- name: Create Git Tag
|
- name: Create Git Tag
|
||||||
if: steps.check_update.outputs.update_needed == 'true'
|
if: steps.check_update.outputs.php_updated == 'true'
|
||||||
run: |
|
run: |
|
||||||
APP_VERSION="${{ steps.php.outputs.app_version }}"
|
APP_VERSION="${{ steps.php.outputs.app_version }}"
|
||||||
|
|
||||||
|
# タグが既に存在する場合はスキップ
|
||||||
|
if git rev-parse "v$APP_VERSION" >/dev/null 2>&1; then
|
||||||
|
echo "Tag v$APP_VERSION already exists, skipping tag creation"
|
||||||
|
else
|
||||||
git tag -a "v$APP_VERSION" -m "Release PHP $APP_VERSION"
|
git tag -a "v$APP_VERSION" -m "Release PHP $APP_VERSION"
|
||||||
git push origin "v$APP_VERSION"
|
git push origin "v$APP_VERSION"
|
||||||
echo "Git tag v$APP_VERSION created"
|
echo "Git tag v$APP_VERSION created"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Create Gitea Release
|
- name: Create Gitea Release
|
||||||
if: steps.check_update.outputs.update_needed == 'true'
|
if: steps.check_update.outputs.php_updated == 'true'
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
@@ -210,13 +247,19 @@ jobs:
|
|||||||
CHART_NAME=$(grep '^name:' Chart.yaml | awk '{print $2}')
|
CHART_NAME=$(grep '^name:' Chart.yaml | awk '{print $2}')
|
||||||
PACKAGE_FILE="${CHART_NAME}-${APP_VERSION}.tgz"
|
PACKAGE_FILE="${CHART_NAME}-${APP_VERSION}.tgz"
|
||||||
RELEASE_BODY="PHP Helm Chart v${APP_VERSION} - Automated release"
|
RELEASE_BODY="PHP Helm Chart v${APP_VERSION} - Automated release"
|
||||||
|
|
||||||
|
# リリースが既に存在する場合はスキップ
|
||||||
|
if curl -s -H "Authorization: token ${GITEA_TOKEN}" "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/v${APP_VERSION}" | jq -e '.id' >/dev/null 2>&1; then
|
||||||
|
echo "Release v$APP_VERSION already exists, skipping release creation"
|
||||||
|
else
|
||||||
curl -X POST -H "Authorization: token ${GITEA_TOKEN}" -H "Content-Type: application/json" -d "{\"tag_name\":\"v${APP_VERSION}\",\"name\":\"v${APP_VERSION}\",\"body\":\"${RELEASE_BODY}\"}" "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases"
|
curl -X POST -H "Authorization: token ${GITEA_TOKEN}" -H "Content-Type: application/json" -d "{\"tag_name\":\"v${APP_VERSION}\",\"name\":\"v${APP_VERSION}\",\"body\":\"${RELEASE_BODY}\"}" "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases"
|
||||||
RELEASE_ID=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/v${APP_VERSION}" | jq -r '.id')
|
RELEASE_ID=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/v${APP_VERSION}" | jq -r '.id')
|
||||||
curl -X POST -H "Authorization: token ${GITEA_TOKEN}" -H "Content-Type: application/gzip" --data-binary "@${PACKAGE_FILE}" "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${PACKAGE_FILE}"
|
curl -X POST -H "Authorization: token ${GITEA_TOKEN}" -H "Content-Type: application/gzip" --data-binary "@${PACKAGE_FILE}" "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${PACKAGE_FILE}"
|
||||||
echo "Release created"
|
echo "Release created"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Update Helm Repository Index
|
- name: Update Helm Repository Index
|
||||||
if: steps.check_update.outputs.update_needed == 'true'
|
if: steps.check_update.outputs.php_updated == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
APP_VERSION="${{ steps.php.outputs.app_version }}"
|
APP_VERSION="${{ steps.php.outputs.app_version }}"
|
||||||
@@ -270,7 +313,16 @@ jobs:
|
|||||||
APP_VERSION="${{ steps.php.outputs.app_version }}"
|
APP_VERSION="${{ steps.php.outputs.app_version }}"
|
||||||
NGINX_VERSION="${{ steps.nginx.outputs.latest }}"
|
NGINX_VERSION="${{ steps.nginx.outputs.latest }}"
|
||||||
SELENIUM_VERSION="${{ steps.selenium.outputs.latest }}"
|
SELENIUM_VERSION="${{ steps.selenium.outputs.latest }}"
|
||||||
|
PHP_UPDATED="${{ steps.check_update.outputs.php_updated }}"
|
||||||
|
|
||||||
echo "Update completed!"
|
echo "Update completed!"
|
||||||
echo "- PHP: ${APP_VERSION}"
|
echo "- PHP: ${APP_VERSION}"
|
||||||
echo "- Nginx: ${NGINX_VERSION}"
|
echo "- Nginx: ${NGINX_VERSION}"
|
||||||
echo "- Selenium: ${SELENIUM_VERSION}"
|
echo "- Selenium: ${SELENIUM_VERSION}"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
if [ "$PHP_UPDATED" = "true" ]; then
|
||||||
|
echo "✅ PHP version updated - Release created (v${APP_VERSION})"
|
||||||
|
else
|
||||||
|
echo "ℹ️ Nginx/Selenium only update - No release (waiting for next PHP update)"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user