From 89452715754da3e59f582ea6c9321415b28e2ecc Mon Sep 17 00:00:00 2001 From: pieter Date: Sat, 10 Jan 2026 11:12:45 +0000 Subject: [PATCH] =?UTF-8?q?.gitea/workflows/image-update-and-release.yaml?= =?UTF-8?q?=20=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/image-update-and-release.yaml | 94 ++++++++++++++++--- 1 file changed, 81 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/image-update-and-release.yaml b/.gitea/workflows/image-update-and-release.yaml index db8b9bb..84cd8f0 100644 --- a/.gitea/workflows/image-update-and-release.yaml +++ b/.gitea/workflows/image-update-and-release.yaml @@ -26,7 +26,13 @@ jobs: echo "Checking nginx versions..." CURRENT=$(grep -A3 "nginx:" values.yaml | grep "tag:" | head -1 | sed 's/.*tag: *"\([^"]*\)".*/\1/' | tr -d ' ') echo "Current nginx: $CURRENT" - LATEST=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/nginx/tags?page_size=100&name=alpine-perl" | jq -r '.results[].name' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpine-perl$' | sort -V | tail -1) + + # Docker Hub API v2を使用してタグを取得 + LATEST=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/nginx/tags?page_size=100" | \ + jq -r '.results[].name' | \ + grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpine-perl$' | \ + sort -V | tail -1) + if [ -z "$LATEST" ]; then echo "Warning: Could not fetch latest nginx version, using current" LATEST="$CURRENT" @@ -42,33 +48,71 @@ jobs: echo "Checking PHP versions..." CURRENT=$(grep -A3 "php:" values.yaml | grep "tag:" | head -1 | sed 's/.*tag: *"\([^"]*\)".*/\1/' | tr -d ' ') echo "Current PHP: $CURRENT" - LATEST=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/php/tags?page_size=100&name=fpm-alpine" | jq -r '.results[].name' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-php[0-9]+\.[0-9]+-fpm-alpine$' | sort -V | tail -1) + + # Docker Hub API v2を使用してタグを取得 + # パターン: 8.4.12-fpm-alpine3.22 形式 + LATEST=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/php/tags?page_size=100" | \ + jq -r '.results[].name' | \ + grep -E '^[0-9]+\.[0-9]+\.[0-9]+-fpm-alpine[0-9]+\.[0-9]+$' | \ + sort -V | tail -1) + if [ -z "$LATEST" ]; then echo "Warning: Could not fetch latest PHP version, using current" LATEST="$CURRENT" fi + + # PHPバージョンを抽出 (8.4.12の部分) APP_VERSION=$(echo "$LATEST" | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+') if [ -z "$APP_VERSION" ]; then echo "Error: Could not extract PHP version" exit 1 fi + echo "Latest PHP: $LATEST" echo "PHP version: $APP_VERSION" echo "current=$CURRENT" >> $GITHUB_OUTPUT echo "latest=$LATEST" >> $GITHUB_OUTPUT echo "app_version=$APP_VERSION" >> $GITHUB_OUTPUT + - name: Check for new Selenium version + id: selenium + run: | + set -e + echo "Checking Selenium versions..." + CURRENT=$(grep -A3 "selenium:" values.yaml | grep "tag:" | head -1 | sed 's/.*tag: *"\([^"]*\)".*/\1/' | tr -d ' ') + echo "Current Selenium: $CURRENT" + + # Docker Hub API v2を使用してタグを取得 + # パターン: 139.0-chromedriver-139.0 形式 + LATEST=$(curl -s "https://registry.hub.docker.com/v2/repositories/selenium/standalone-chromium/tags?page_size=100" | \ + jq -r '.results[].name' | \ + grep -E '^[0-9]+\.[0-9]+-chromedriver-[0-9]+\.[0-9]+$' | \ + sort -V | tail -1) + + if [ -z "$LATEST" ]; then + echo "Warning: Could not fetch latest Selenium version, using current" + LATEST="$CURRENT" + fi + echo "Latest Selenium: $LATEST" + echo "current=$CURRENT" >> $GITHUB_OUTPUT + echo "latest=$LATEST" >> $GITHUB_OUTPUT + - name: Determine if update is needed id: check_update run: | set -e NGINX_CURRENT="${{ steps.nginx.outputs.current }}" NGINX_LATEST="${{ steps.nginx.outputs.latest }}" - APP_CURRENT="${{ steps.php.outputs.current }}" - APP_LATEST="${{ steps.php.outputs.latest }}" + PHP_CURRENT="${{ steps.php.outputs.current }}" + PHP_LATEST="${{ steps.php.outputs.latest }}" + SELENIUM_CURRENT="${{ steps.selenium.outputs.current }}" + SELENIUM_LATEST="${{ steps.selenium.outputs.latest }}" + echo "Nginx: $NGINX_CURRENT vs $NGINX_LATEST" - echo "PHP: $APP_CURRENT vs $APP_LATEST" - if [ "$NGINX_CURRENT" != "$NGINX_LATEST" ] || [ "$APP_CURRENT" != "$APP_LATEST" ]; then + echo "PHP: $PHP_CURRENT vs $PHP_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 echo "Update is needed" else @@ -81,12 +125,31 @@ jobs: run: | set -e echo "Updating values.yaml..." + + # Nginx更新 NGINX_OLD="${{ steps.nginx.outputs.current }}" NGINX_NEW="${{ steps.nginx.outputs.latest }}" - sed -i "s|tag: \"${NGINX_OLD}\"|tag: \"${NGINX_NEW}\"|g" values.yaml - APP_OLD="${{ steps.php.outputs.current }}" - APP_NEW="${{ steps.php.outputs.latest }}" - sed -i "s|tag: \"${APP_OLD}\"|tag: \"${APP_NEW}\"|g" values.yaml + if [ "$NGINX_OLD" != "$NGINX_NEW" ]; then + sed -i "s|tag: \"${NGINX_OLD}\"|tag: \"${NGINX_NEW}\"|g" values.yaml + echo "Nginx updated: $NGINX_OLD -> $NGINX_NEW" + fi + + # PHP更新 + PHP_OLD="${{ steps.php.outputs.current }}" + PHP_NEW="${{ steps.php.outputs.latest }}" + if [ "$PHP_OLD" != "$PHP_NEW" ]; then + sed -i "s|tag: \"${PHP_OLD}\"|tag: \"${PHP_NEW}\"|g" values.yaml + echo "PHP updated: $PHP_OLD -> $PHP_NEW" + fi + + # Selenium更新 + SELENIUM_OLD="${{ steps.selenium.outputs.current }}" + SELENIUM_NEW="${{ steps.selenium.outputs.latest }}" + if [ "$SELENIUM_OLD" != "$SELENIUM_NEW" ]; then + sed -i "s|tag: \"${SELENIUM_OLD}\"|tag: \"${SELENIUM_NEW}\"|g" values.yaml + echo "Selenium updated: $SELENIUM_OLD -> $SELENIUM_NEW" + fi + echo "values.yaml updated" git diff values.yaml @@ -106,7 +169,7 @@ jobs: git config user.name "GitHub Actions Bot" git config user.email "actions@github.com" git add values.yaml Chart.yaml - git commit -m "chore: update to PHP ${{ steps.php.outputs.app_version }}" + git commit -m "chore: update to PHP ${{ steps.php.outputs.app_version }}, nginx ${{ steps.nginx.outputs.latest }}, selenium ${{ steps.selenium.outputs.latest }}" git push origin main - name: Package Helm Chart @@ -172,7 +235,7 @@ jobs: cp /tmp/helm-repo/"${PACKAGE_FILE}" . # index.yamlを生成/更新 - helm repo index . --url "https://gitea.example.com/${GITHUB_REPOSITORY}/raw/branch/gh-pages" + helm repo index . --url "https://git.cafepieters.com/${GITHUB_REPOSITORY}/raw/branch/gh-pages" # コミットしてプッシュ git config user.name "GitHub Actions Bot" @@ -190,4 +253,9 @@ jobs: if: steps.check_update.outputs.update_needed == 'true' run: | APP_VERSION="${{ steps.php.outputs.app_version }}" - echo "Update completed to version ${APP_VERSION}" \ No newline at end of file + NGINX_VERSION="${{ steps.nginx.outputs.latest }}" + SELENIUM_VERSION="${{ steps.selenium.outputs.latest }}" + echo "Update completed!" + echo "- PHP: ${APP_VERSION}" + echo "- Nginx: ${NGINX_VERSION}" + echo "- Selenium: ${SELENIUM_VERSION}" \ No newline at end of file