From 58f0b77a4a2cfa83f2f695a6aa2fafb84897ef38 Mon Sep 17 00:00:00 2001 From: Patryk Ciechanski Date: Thu, 12 Jun 2025 10:20:44 +0200 Subject: [PATCH] feat: Add automatic README.md updating after Docker builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Updates Docker image references in README.md and documentation files - Automatically commits and pushes changes after image builds - Handles both release builds (version tags) and development builds (PR numbers) - Ensures documentation always references the latest published images - Uses sed pattern matching to update ghcr.io image references 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../workflows/build_and_publish_docker.yml | 63 ++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_publish_docker.yml b/.github/workflows/build_and_publish_docker.yml index 2c9e2f7..43b46c0 100644 --- a/.github/workflows/build_and_publish_docker.yml +++ b/.github/workflows/build_and_publish_docker.yml @@ -113,4 +113,65 @@ jobs: echo "" >> $GITHUB_STEP_SUMMARY echo "### 📦 View in GitHub Container Registry" >> $GITHUB_STEP_SUMMARY - echo "[View all versions and tags →](https://github.com/${{ github.repository }}/pkgs/container/gemini-mcp-server)" >> $GITHUB_STEP_SUMMARY \ No newline at end of file + echo "[View all versions and tags →](https://github.com/${{ github.repository }}/pkgs/container/gemini-mcp-server)" >> $GITHUB_STEP_SUMMARY + + - name: Update README with latest image info + if: github.ref_type == 'tag' || github.event_name == 'repository_dispatch' + run: | + # Extract the primary image tag for updating README + if [[ "${{ github.ref_type }}" == "tag" ]]; then + # For tag releases, use the version tag + LATEST_TAG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}" + UPDATE_TYPE="release" + else + # For repository_dispatch (PR builds), use the PR tag + LATEST_TAG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:pr-${{ github.event.client_payload.pr_number }}" + UPDATE_TYPE="development" + fi + + echo "Updating README.md with latest Docker image: $LATEST_TAG" + + # Update README.md with the latest image tag + sed -i.bak "s|ghcr\.io/patrykiti/gemini-mcp-server:[a-zA-Z0-9\.-]*|$LATEST_TAG|g" README.md + + # Also update docs/user-guides/installation.md + sed -i.bak "s|ghcr\.io/patrykiti/gemini-mcp-server:[a-zA-Z0-9\.-]*|$LATEST_TAG|g" docs/user-guides/installation.md + + # Also update docs/user-guides/configuration.md + sed -i.bak "s|ghcr\.io/patrykiti/gemini-mcp-server:[a-zA-Z0-9\.-]*|$LATEST_TAG|g" docs/user-guides/configuration.md + + # Check if there are any changes + if git diff --quiet README.md docs/user-guides/installation.md docs/user-guides/configuration.md; then + echo "No changes needed in documentation" + else + echo "Documentation updated with new image tag" + + # Configure git for automated commit + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + # Add and commit changes + git add README.md docs/user-guides/installation.md docs/user-guides/configuration.md + + if [[ "$UPDATE_TYPE" == "release" ]]; then + git commit -m "docs: Update Docker image references to ${{ github.ref_name }} + +Automated update after Docker image publish for release ${{ github.ref_name }}. +All documentation now references the latest stable image. + +🤖 Automated by GitHub Actions" + else + git commit -m "docs: Update Docker image references for PR #${{ github.event.client_payload.pr_number }} + +Automated update after Docker image publish for development build. +Documentation updated to reference the latest development image. + +🤖 Automated by GitHub Actions" + fi + + # Push changes back to the repository + git push + + echo "### 📝 Documentation Updated" >> $GITHUB_STEP_SUMMARY + echo "README.md and user guides have been automatically updated with the new Docker image tag: \`$LATEST_TAG\`" >> $GITHUB_STEP_SUMMARY + fi \ No newline at end of file