fix: Revert to jq with proper URL filtering
All checks were successful
Helm Chart Release / release-chart (push) Successful in 11s
All checks were successful
Helm Chart Release / release-chart (push) Successful in 11s
Pythonアプローチで発生したYAMLエラーを解消。 jqベースに戻し、Docker Hub APIのnameパラメータで効率的にフィルタ。 Changes: - Pythonスクリプトを削除(YAMLインデント問題の原因) - jqベースのシンプルなパイプラインに戻す - URLに&name=fpm-alpineパラメータを追加(必須) - jqの自動インストールを追加(念のため) - 正規表現パターンを維持(alpine 2-3桁対応) - デバッグ出力を維持 URL: https://registry.hub.docker.com/v2/repositories/library/php/tags?page_size=100&name=fpm-alpine Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -49,49 +49,18 @@ jobs:
|
|||||||
CURRENT=$(grep -A3 "php:" values.yaml | grep "tag:" | head -1 | sed 's/.*tag: *"\([^"]*\)".*/\1/' | tr -d ' ')
|
CURRENT=$(grep -A3 "php:" values.yaml | grep "tag:" | head -1 | sed 's/.*tag: *"\([^"]*\)".*/\1/' | tr -d ' ')
|
||||||
echo "Current PHP: $CURRENT"
|
echo "Current PHP: $CURRENT"
|
||||||
|
|
||||||
# Docker Hub API v2を使用してタグを取得
|
# jqの確認とインストール
|
||||||
|
if ! command -v jq &> /dev/null; then
|
||||||
|
echo "jq not found, installing..."
|
||||||
|
sudo apt-get update -qq && sudo apt-get install -y -qq jq
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Docker Hub API v2を使用してタグを取得(fpm-alpineでフィルタ)
|
||||||
echo "Fetching tags from Docker Hub..."
|
echo "Fetching tags from Docker Hub..."
|
||||||
|
LATEST=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/php/tags?page_size=100&name=fpm-alpine" | \
|
||||||
# Pythonを使用してJSONをパースし、タグを抽出
|
jq -r '.results[].name' | \
|
||||||
LATEST=$(python3 << 'PYTHON_SCRIPT'
|
grep -E '^[0-9]+\.[0-9]+\.[0-9]+-fpm-alpine[0-9]+\.[0-9]{2,3}$' | \
|
||||||
import sys
|
sort -V | tail -1)
|
||||||
import urllib.request
|
|
||||||
import json
|
|
||||||
import re
|
|
||||||
|
|
||||||
url = "https://registry.hub.docker.com/v2/repositories/library/php/tags?page_size=100"
|
|
||||||
try:
|
|
||||||
with urllib.request.urlopen(url) as response:
|
|
||||||
data = json.loads(response.read())
|
|
||||||
tags = [result['name'] for result in data.get('results', [])]
|
|
||||||
|
|
||||||
# パターン: 8.5.2-fpm-alpine3.23 形式
|
|
||||||
pattern = re.compile(r'^\d+\.\d+\.\d+-fpm-alpine\d+\.\d{2,3}$')
|
|
||||||
matching_tags = [tag for tag in tags if pattern.match(tag)]
|
|
||||||
|
|
||||||
# デバッグ出力
|
|
||||||
print("DEBUG: Available PHP tags (first 10):", file=sys.stderr)
|
|
||||||
for tag in [t for t in tags if 'fpm-alpine' in t][:10]:
|
|
||||||
print(f" {tag}", file=sys.stderr)
|
|
||||||
|
|
||||||
print(f"DEBUG: Matching tags count: {len(matching_tags)}", file=sys.stderr)
|
|
||||||
|
|
||||||
if matching_tags:
|
|
||||||
# バージョンソート
|
|
||||||
def version_key(tag):
|
|
||||||
parts = tag.split('-')[0].split('.')
|
|
||||||
return tuple(int(p) for p in parts)
|
|
||||||
|
|
||||||
sorted_tags = sorted(matching_tags, key=version_key)
|
|
||||||
latest = sorted_tags[-1]
|
|
||||||
print(latest)
|
|
||||||
else:
|
|
||||||
print("", end="")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"ERROR: {e}", file=sys.stderr)
|
|
||||||
print("", end="")
|
|
||||||
PYTHON_SCRIPT
|
|
||||||
)
|
|
||||||
|
|
||||||
echo "DEBUG: Matched LATEST=$LATEST"
|
echo "DEBUG: Matched LATEST=$LATEST"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user