定期動作していなかったため修正
This commit is contained in:
@@ -1,193 +1,318 @@
|
|||||||
name: Update Docker Image Tags and Release Helm Chart
|
name: Update Docker Images and Helm Chart
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 2 * * 1'
|
- cron: "0 0 * * 0" # 毎週日曜日 00:00 UTC
|
||||||
workflow_dispatch:
|
workflow_dispatch: # 手動実行も可能にする
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-and-release:
|
update:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write # Git pushに必要な権限を明示的に付与
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0 # 完全な履歴を取得
|
||||||
|
token: ${{ secrets.GITEA_TOKEN || github.token }} # トークンを明示的に指定
|
||||||
|
|
||||||
- name: Install Helm
|
- name: Set up Git
|
||||||
uses: azure/setup-helm@v3
|
|
||||||
with:
|
|
||||||
version: 'v3.12.0'
|
|
||||||
|
|
||||||
- name: Check for new nginx version
|
|
||||||
id: nginx
|
|
||||||
run: |
|
run: |
|
||||||
set -e
|
git config user.name "Gitea Actions"
|
||||||
echo "Checking nginx versions..."
|
git config user.email "actions@git.cafepieters.com"
|
||||||
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)
|
|
||||||
if [ -z "$LATEST" ]; then
|
|
||||||
echo "Warning: Could not fetch latest nginx version, using current"
|
|
||||||
LATEST="$CURRENT"
|
|
||||||
fi
|
|
||||||
echo "Latest nginx: $LATEST"
|
|
||||||
echo "current=$CURRENT" >> $GITHUB_OUTPUT
|
|
||||||
echo "latest=$LATEST" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Check for new WordPress version
|
- name: Fetch latest WordPress FPM Alpine version
|
||||||
id: wordpress
|
id: wordpress
|
||||||
run: |
|
run: |
|
||||||
set -e
|
# Docker Hubから最新のWordPress FPM Alpineバージョンを取得(PHPバージョンも最新)
|
||||||
echo "Checking WordPress versions..."
|
echo "Fetching WordPress FPM Alpine versions..."
|
||||||
CURRENT=$(grep -A3 "wordpress:" values.yaml | grep "tag:" | head -1 | sed 's/.*tag: *"\([^"]*\)".*/\1/' | tr -d ' ')
|
|
||||||
echo "Current WordPress: $CURRENT"
|
# fpm-alpineタグを取得(全PHPバージョン対象)
|
||||||
LATEST=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/wordpress/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)
|
LATEST_VERSION=$(curl -s "https://hub.docker.com/v2/repositories/library/wordpress/tags?page_size=100&name=fpm-alpine" | \
|
||||||
if [ -z "$LATEST" ]; then
|
jq -r '.results[].name' | \
|
||||||
echo "Warning: Could not fetch latest WordPress version, using current"
|
grep -E '^[0-9]+\.[0-9]+(\.[0-9]+)?-php[0-9]+\.[0-9]+-fpm-alpine$' | \
|
||||||
LATEST="$CURRENT"
|
grep -v 'rc' | \
|
||||||
|
grep -v 'beta' | \
|
||||||
|
grep -v 'alpha' | \
|
||||||
|
sort -t- -k1,1V -k2,2V | \
|
||||||
|
tail -n 1)
|
||||||
|
|
||||||
|
if [ -z "$LATEST_VERSION" ]; then
|
||||||
|
echo "Failed to fetch from first method, trying alternative..."
|
||||||
|
# 代替方法: すべてのfpm-alpineタグを取得
|
||||||
|
LATEST_VERSION=$(curl -s "https://hub.docker.com/v2/repositories/library/wordpress/tags?page_size=100" | \
|
||||||
|
jq -r '.results[].name' | \
|
||||||
|
grep -E '^[0-9]+\.[0-9]+\.[0-9]+-php[0-9]+\.[0-9]+-fpm-alpine$' | \
|
||||||
|
grep -v 'rc' | \
|
||||||
|
grep -v 'beta' | \
|
||||||
|
grep -v 'alpha' | \
|
||||||
|
sort -t- -k1,1V -k2,2V | \
|
||||||
|
tail -n 1)
|
||||||
fi
|
fi
|
||||||
WP_VERSION=$(echo "$LATEST" | grep -oE '^[0-9]+\.[0-9]+\.[0-9]+')
|
|
||||||
if [ -z "$WP_VERSION" ]; then
|
if [ -z "$LATEST_VERSION" ]; then
|
||||||
echo "Error: Could not extract WordPress version"
|
echo "ERROR: Failed to fetch WordPress version"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Latest WordPress: $LATEST"
|
|
||||||
echo "WordPress version: $WP_VERSION"
|
|
||||||
echo "current=$CURRENT" >> $GITHUB_OUTPUT
|
|
||||||
echo "latest=$LATEST" >> $GITHUB_OUTPUT
|
|
||||||
echo "wp_version=$WP_VERSION" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Determine if update is needed
|
echo "WordPress latest version: $LATEST_VERSION"
|
||||||
id: check_update
|
|
||||||
|
# バージョン情報を分解して表示
|
||||||
|
WP_VERSION=$(echo $LATEST_VERSION | cut -d'-' -f1)
|
||||||
|
PHP_VERSION=$(echo $LATEST_VERSION | cut -d'-' -f2)
|
||||||
|
echo " WordPress: $WP_VERSION"
|
||||||
|
echo " PHP: $PHP_VERSION"
|
||||||
|
echo " Base: fpm-alpine"
|
||||||
|
|
||||||
|
echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Fetch latest Nginx Alpine Perl version
|
||||||
|
id: nginx
|
||||||
run: |
|
run: |
|
||||||
set -e
|
# Docker Hubから最新のNginx Alpine Perlバージョンを取得
|
||||||
NGINX_CURRENT="${{ steps.nginx.outputs.current }}"
|
echo "Fetching Nginx Alpine Perl versions..."
|
||||||
NGINX_LATEST="${{ steps.nginx.outputs.latest }}"
|
|
||||||
WP_CURRENT="${{ steps.wordpress.outputs.current }}"
|
LATEST_VERSION=$(curl -s "https://hub.docker.com/v2/repositories/library/nginx/tags?page_size=100&name=alpine-perl" | \
|
||||||
WP_LATEST="${{ steps.wordpress.outputs.latest }}"
|
jq -r '.results[].name' | \
|
||||||
echo "Nginx: $NGINX_CURRENT vs $NGINX_LATEST"
|
grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpine-perl$' | \
|
||||||
echo "WordPress: $WP_CURRENT vs $WP_LATEST"
|
grep -v 'rc' | \
|
||||||
if [ "$NGINX_CURRENT" != "$NGINX_LATEST" ] || [ "$WP_CURRENT" != "$WP_LATEST" ]; then
|
grep -v 'beta' | \
|
||||||
echo "update_needed=true" >> $GITHUB_OUTPUT
|
grep -v 'alpha' | \
|
||||||
echo "Update is needed"
|
sort -V | \
|
||||||
else
|
tail -n 1)
|
||||||
echo "update_needed=false" >> $GITHUB_OUTPUT
|
|
||||||
echo "Already up to date"
|
if [ -z "$LATEST_VERSION" ]; then
|
||||||
|
echo "Failed to fetch from first method, trying alternative..."
|
||||||
|
# 代替方法: alpine-perlタグを別の方法で検索
|
||||||
|
LATEST_VERSION=$(curl -s "https://hub.docker.com/v2/repositories/library/nginx/tags?page_size=100" | \
|
||||||
|
jq -r '.results[].name' | \
|
||||||
|
grep 'alpine-perl$' | \
|
||||||
|
grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpine-perl$' | \
|
||||||
|
grep -v 'rc' | \
|
||||||
|
grep -v 'beta' | \
|
||||||
|
grep -v 'alpha' | \
|
||||||
|
sort -V | \
|
||||||
|
tail -n 1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$LATEST_VERSION" ]; then
|
||||||
|
echo "ERROR: Failed to fetch Nginx version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Nginx latest version: $LATEST_VERSION"
|
||||||
|
|
||||||
|
# バージョン情報を表示
|
||||||
|
NGINX_VERSION=$(echo $LATEST_VERSION | cut -d'-' -f1)
|
||||||
|
echo " Nginx: $NGINX_VERSION"
|
||||||
|
echo " Base: alpine-perl"
|
||||||
|
|
||||||
|
echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Get current versions from values.yaml
|
||||||
|
id: current
|
||||||
|
run: |
|
||||||
|
# 現在のバージョンを取得
|
||||||
|
CURRENT_WORDPRESS=$(grep -A 3 'wordpress:' values.yaml | grep 'tag:' | awk -F'"' '{print $2}')
|
||||||
|
CURRENT_NGINX=$(grep -A 3 'nginx:' values.yaml | grep 'tag:' | awk -F'"' '{print $2}')
|
||||||
|
|
||||||
|
echo "current_wordpress=$CURRENT_WORDPRESS" >> $GITHUB_OUTPUT
|
||||||
|
echo "current_nginx=$CURRENT_NGINX" >> $GITHUB_OUTPUT
|
||||||
|
echo "Current WordPress: $CURRENT_WORDPRESS"
|
||||||
|
echo "Current Nginx: $CURRENT_NGINX"
|
||||||
|
|
||||||
|
- name: Check if update is needed
|
||||||
|
id: check
|
||||||
|
run: |
|
||||||
|
UPDATE_NEEDED=false
|
||||||
|
CHANGES=""
|
||||||
|
|
||||||
|
if [ "${{ steps.current.outputs.current_wordpress }}" != "${{ steps.wordpress.outputs.version }}" ]; then
|
||||||
|
echo "WordPress update available: ${{ steps.current.outputs.current_wordpress }} -> ${{ steps.wordpress.outputs.version }}"
|
||||||
|
UPDATE_NEEDED=true
|
||||||
|
CHANGES="${CHANGES}- WordPress: ${{ steps.current.outputs.current_wordpress }} -> ${{ steps.wordpress.outputs.version }}\n"
|
||||||
|
else
|
||||||
|
echo "WordPress is up to date: ${{ steps.current.outputs.current_wordpress }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${{ steps.current.outputs.current_nginx }}" != "${{ steps.nginx.outputs.version }}" ]; then
|
||||||
|
echo "Nginx update available: ${{ steps.current.outputs.current_nginx }} -> ${{ steps.nginx.outputs.version }}"
|
||||||
|
UPDATE_NEEDED=true
|
||||||
|
CHANGES="${CHANGES}- Nginx: ${{ steps.current.outputs.current_nginx }} -> ${{ steps.nginx.outputs.version }}\n"
|
||||||
|
else
|
||||||
|
echo "Nginx is up to date: ${{ steps.current.outputs.current_nginx }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "update_needed=$UPDATE_NEEDED" >> $GITHUB_OUTPUT
|
||||||
|
echo -e "changes<<EOF" >> $GITHUB_OUTPUT
|
||||||
|
echo -e "$CHANGES" >> $GITHUB_OUTPUT
|
||||||
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Update values.yaml
|
- name: Update values.yaml
|
||||||
if: steps.check_update.outputs.update_needed == 'true'
|
if: steps.check.outputs.update_needed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
# バックアップを作成
|
||||||
echo "Updating values.yaml..."
|
cp values.yaml values.yaml.bak
|
||||||
NGINX_OLD="${{ steps.nginx.outputs.current }}"
|
|
||||||
NGINX_NEW="${{ steps.nginx.outputs.latest }}"
|
|
||||||
sed -i "s|tag: \"${NGINX_OLD}\"|tag: \"${NGINX_NEW}\"|g" values.yaml
|
|
||||||
WP_OLD="${{ steps.wordpress.outputs.current }}"
|
|
||||||
WP_NEW="${{ steps.wordpress.outputs.latest }}"
|
|
||||||
sed -i "s|tag: \"${WP_OLD}\"|tag: \"${WP_NEW}\"|g" values.yaml
|
|
||||||
echo "values.yaml updated"
|
|
||||||
git diff values.yaml
|
|
||||||
|
|
||||||
- name: Update Chart.yaml version
|
# WordPressのtagを更新
|
||||||
if: steps.check_update.outputs.update_needed == 'true'
|
# image.wordpress.tagの行を特定して置換
|
||||||
run: |
|
awk -v new_tag="${{ steps.wordpress.outputs.version }}" '
|
||||||
set -e
|
/^image:/ { in_image=1 }
|
||||||
WP_VERSION="${{ steps.wordpress.outputs.wp_version }}"
|
in_image && /^ wordpress:/ { in_wordpress=1; print; next }
|
||||||
sed -i "s/^version: .*/version: $WP_VERSION/" Chart.yaml
|
in_wordpress && /^ tag:/ {
|
||||||
sed -i "s/^appVersion: .*/appVersion: \"$WP_VERSION\"/" Chart.yaml
|
print " tag: \"" new_tag "\""
|
||||||
echo "Chart.yaml updated to version $WP_VERSION"
|
in_wordpress=0
|
||||||
cat Chart.yaml
|
next
|
||||||
|
}
|
||||||
|
in_wordpress && /^ [a-z]/ { in_wordpress=0 }
|
||||||
|
in_image && /^[a-z]/ { in_image=0 }
|
||||||
|
{ print }
|
||||||
|
' values.yaml.bak > values.yaml.tmp
|
||||||
|
mv values.yaml.tmp values.yaml
|
||||||
|
|
||||||
- name: Commit changes
|
# Nginxのtagを更新
|
||||||
if: steps.check_update.outputs.update_needed == 'true'
|
cp values.yaml values.yaml.tmp
|
||||||
run: |
|
awk -v new_tag="${{ steps.nginx.outputs.version }}" '
|
||||||
git config user.name "GitHub Actions Bot"
|
/^image:/ { in_image=1 }
|
||||||
git config user.email "actions@github.com"
|
in_image && /^ nginx:/ { in_nginx=1; print; next }
|
||||||
git add values.yaml Chart.yaml
|
in_nginx && /^ tag:/ {
|
||||||
git commit -m "chore: update to WordPress ${{ steps.wordpress.outputs.wp_version }}"
|
print " tag: \"" new_tag "\""
|
||||||
git push origin main
|
in_nginx=0
|
||||||
|
next
|
||||||
|
}
|
||||||
|
in_nginx && /^ [a-z]/ { in_nginx=0 }
|
||||||
|
in_image && /^[a-z]/ { in_image=0 }
|
||||||
|
{ print }
|
||||||
|
' values.yaml.tmp > values.yaml
|
||||||
|
rm values.yaml.tmp
|
||||||
|
|
||||||
- name: Package Helm Chart
|
# 変更内容を表示
|
||||||
if: steps.check_update.outputs.update_needed == 'true'
|
echo "=== Changes in values.yaml ==="
|
||||||
run: |
|
diff values.yaml.bak values.yaml || true
|
||||||
helm package .
|
|
||||||
echo "Helm chart packaged"
|
|
||||||
|
|
||||||
- name: Create Git Tag
|
# 実際に変更されたか確認
|
||||||
if: steps.check_update.outputs.update_needed == 'true'
|
if diff -q values.yaml.bak values.yaml > /dev/null; then
|
||||||
run: |
|
echo "ERROR: No changes were made to values.yaml"
|
||||||
WP_VERSION="${{ steps.wordpress.outputs.wp_version }}"
|
cat values.yaml | grep -A 5 "image:"
|
||||||
git tag -a "v$WP_VERSION" -m "Release WordPress $WP_VERSION"
|
exit 1
|
||||||
git push origin "v$WP_VERSION"
|
|
||||||
echo "Git tag v$WP_VERSION created"
|
|
||||||
|
|
||||||
- name: Create Gitea Release
|
|
||||||
if: steps.check_update.outputs.update_needed == 'true'
|
|
||||||
env:
|
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
run: |
|
|
||||||
WP_VERSION="${{ steps.wordpress.outputs.wp_version }}"
|
|
||||||
CHART_NAME=$(grep '^name:' Chart.yaml | awk '{print $2}')
|
|
||||||
PACKAGE_FILE="${CHART_NAME}-${WP_VERSION}.tgz"
|
|
||||||
RELEASE_BODY="WordPress Helm Chart v${WP_VERSION} - Automated release"
|
|
||||||
curl -X POST -H "Authorization: token ${GITEA_TOKEN}" -H "Content-Type: application/json" -d "{\"tag_name\":\"v${WP_VERSION}\",\"name\":\"v${WP_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${WP_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}"
|
|
||||||
echo "Release created"
|
|
||||||
|
|
||||||
- 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"
|
|
||||||
|
|
||||||
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
|
fi
|
||||||
|
|
||||||
# パッケージファイルをコピー
|
echo "=== Updated values.yaml (image section) ==="
|
||||||
cp /tmp/helm-repo/"${PACKAGE_FILE}" .
|
grep -A 10 "^image:" values.yaml
|
||||||
|
|
||||||
# index.yamlを生成/更新
|
- name: Increment chart version
|
||||||
helm repo index . --url "https://gitea.cafepieters.com/${GITHUB_REPOSITORY}/raw/branch/gh-pages"
|
if: steps.check.outputs.update_needed == 'true'
|
||||||
|
id: increment
|
||||||
|
run: |
|
||||||
|
# Chart.yamlのバージョンをインクリメント
|
||||||
|
if [ -f Chart.yaml ]; then
|
||||||
|
CURRENT_CHART_VERSION=$(grep '^version:' Chart.yaml | awk '{print $2}')
|
||||||
|
# パッチバージョンをインクリメント(例: 1.0.0 -> 1.0.1)
|
||||||
|
NEW_CHART_VERSION=$(echo $CURRENT_CHART_VERSION | awk -F. '{print $1"."$2"."$3+1}')
|
||||||
|
sed -i "s/^version: .*/version: $NEW_CHART_VERSION/" Chart.yaml
|
||||||
|
echo "Chart version updated: $CURRENT_CHART_VERSION -> $NEW_CHART_VERSION"
|
||||||
|
echo "new_chart_version=$NEW_CHART_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "Chart.yaml not found, skipping version increment"
|
||||||
|
echo "new_chart_version=unknown" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
# コミットしてプッシュ
|
- name: Commit and push changes
|
||||||
git config user.name "GitHub Actions Bot"
|
if: steps.check.outputs.update_needed == 'true'
|
||||||
git config user.email "actions@github.com"
|
run: |
|
||||||
git add "${PACKAGE_FILE}" index.yaml
|
git add values.yaml Chart.yaml
|
||||||
git commit -m "chore: add ${CHART_NAME} v${WP_VERSION}" || echo "No changes to commit"
|
git status
|
||||||
git push origin gh-pages
|
|
||||||
|
|
||||||
echo "Helm repository updated successfully"
|
if git diff --staged --quiet; then
|
||||||
|
echo "No changes to commit"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# mainブランチに戻る
|
# コミットメッセージを作成
|
||||||
git checkout main
|
cat << EOF > /tmp/commit_msg.txt
|
||||||
|
chore: Update Docker images
|
||||||
|
|
||||||
|
${{ steps.check.outputs.changes }}
|
||||||
|
Auto-updated by Gitea Actions
|
||||||
|
EOF
|
||||||
|
|
||||||
|
git commit -F /tmp/commit_msg.txt
|
||||||
|
|
||||||
|
# プッシュをリトライ機構付きで実行
|
||||||
|
MAX_RETRIES=3
|
||||||
|
RETRY_COUNT=0
|
||||||
|
until git push origin main || [ $RETRY_COUNT -eq $MAX_RETRIES ]; do
|
||||||
|
RETRY_COUNT=$((RETRY_COUNT+1))
|
||||||
|
echo "Push failed, retrying ($RETRY_COUNT/$MAX_RETRIES)..."
|
||||||
|
sleep 5
|
||||||
|
git pull --rebase origin main
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
|
||||||
|
echo "ERROR: Failed to push after $MAX_RETRIES attempts"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Successfully pushed changes to main branch"
|
||||||
|
|
||||||
|
- name: Install Helm
|
||||||
|
if: steps.check.outputs.update_needed == 'true'
|
||||||
|
uses: azure/setup-helm@v3
|
||||||
|
with:
|
||||||
|
version: 'latest'
|
||||||
|
|
||||||
|
- name: Create Helm package
|
||||||
|
if: steps.check.outputs.update_needed == 'true'
|
||||||
|
run: |
|
||||||
|
# packagesディレクトリを作成
|
||||||
|
mkdir -p ./packages/
|
||||||
|
|
||||||
|
# Helmパッケージを作成
|
||||||
|
helm package . -d ./packages/
|
||||||
|
|
||||||
|
# リポジトリインデックスを更新
|
||||||
|
helm repo index ./packages/ --url https://git.cafepieters.com/helmchart/wordpress/raw/branch/main/packages/
|
||||||
|
|
||||||
|
# パッケージファイルをコミット
|
||||||
|
git add ./packages/*.tgz ./packages/index.yaml
|
||||||
|
git commit -m "chore: Add Helm package for version ${{ steps.increment.outputs.new_chart_version }}" || echo "No package changes to commit"
|
||||||
|
git push origin main || echo "Failed to push packages (this may be expected)"
|
||||||
|
|
||||||
|
- name: Create release tag
|
||||||
|
if: steps.check.outputs.update_needed == 'true'
|
||||||
|
run: |
|
||||||
|
# リリースタグを作成
|
||||||
|
TAG_NAME="v${{ steps.increment.outputs.new_chart_version }}"
|
||||||
|
|
||||||
|
cat << EOF > /tmp/tag_msg.txt
|
||||||
|
Release $TAG_NAME
|
||||||
|
|
||||||
|
${{ steps.check.outputs.changes }}
|
||||||
|
Chart version: ${{ steps.increment.outputs.new_chart_version }}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
git tag -a "$TAG_NAME" -F /tmp/tag_msg.txt
|
||||||
|
git push origin "$TAG_NAME" || echo "Failed to push tag (tag may already exist)"
|
||||||
|
|
||||||
- name: Summary
|
- name: Summary
|
||||||
if: steps.check_update.outputs.update_needed == 'true'
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
WP_VERSION="${{ steps.wordpress.outputs.wp_version }}"
|
echo "=== Workflow Summary ==="
|
||||||
echo "Update completed to version ${WP_VERSION}"
|
echo "Update needed: ${{ steps.check.outputs.update_needed }}"
|
||||||
|
echo ""
|
||||||
|
echo "WordPress:"
|
||||||
|
echo " Current: ${{ steps.current.outputs.current_wordpress }}"
|
||||||
|
echo " Latest: ${{ steps.wordpress.outputs.version }}"
|
||||||
|
echo ""
|
||||||
|
echo "Nginx:"
|
||||||
|
echo " Current: ${{ steps.current.outputs.current_nginx }}"
|
||||||
|
echo " Latest: ${{ steps.nginx.outputs.version }}"
|
||||||
|
|
||||||
|
if [ "${{ steps.check.outputs.update_needed }}" == "true" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "Chart version: ${{ steps.increment.outputs.new_chart_version }}"
|
||||||
|
echo "Tag: v${{ steps.increment.outputs.new_chart_version }}"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user