Conversation
…sting CDN builds Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new Fastlane action to update metadata on an existing Apps CDN build post via the WordPress.com REST API, enabling a two-phase release flow (upload internal → later flip to external without re-upload).
Changes:
- Introduces
update_apps_cdn_build_metadataFastlane action that POSTs updates to an Apps CDN build post (visibility/status). - Adds RSpec coverage for successful updates, validation, and error handling.
- Documents the new action in the Trunk changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| spec/update_apps_cdn_build_metadata_spec.rb | Adds unit tests for the new action’s request shaping, validation, and error cases. |
| lib/fastlane/plugin/wpmreleasetoolkit/actions/common/update_apps_cdn_build_metadata.rb | Implements the new Fastlane action that updates build metadata via WPCOM REST API. |
| CHANGELOG.md | Adds a Trunk “New Features” entry for the new action. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/update_apps_cdn_build_metadata.rb
Show resolved
Hide resolved
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/update_apps_cdn_build_metadata.rb
Show resolved
Hide resolved
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The v1.1 API returns 500 for a8c_cdn_build custom post types.
The WP REST API v2 endpoint works correctly for both reads and writes.
- POST to /wp/v2/sites/{site_id}/a8c_cdn_build/{post_id} with JSON body
- Visibility changes now look up taxonomy term IDs first
- Response uses lowercase 'id' instead of 'ID'
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| def self.lookup_visibility_term_id(site_id:, api_token:, visibility:) | ||
| slug = visibility.to_s.downcase | ||
| api_endpoint = "https://public-api.wordpress.com/wp/v2/sites/#{site_id}/visibility?slug=#{slug}" | ||
| uri = URI.parse(api_endpoint) | ||
|
|
||
| request = Net::HTTP::Get.new(uri.request_uri) | ||
| request['Accept'] = 'application/json' | ||
| request['Authorization'] = "Bearer #{api_token}" | ||
|
|
||
| response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http| | ||
| http.open_timeout = 10 | ||
| http.read_timeout = 30 | ||
| http.request(request) | ||
| end |
There was a problem hiding this comment.
Given the call site will typically call this update_apps_cdn_build_metadata action in a loop (here, this means that the fetching of the visibility term id here would be done many times during the make_cdn_builds_public lane that calls those.
Wouldn't it be better to have update_apps_cdn_build_metadata be able to take an array of post_id values to update the visibility/post_status metadata of, so that it does this lookup_visibility_term_id API call only once while looping on all the posts to update them with the same visibility ID.
Fixes AINFRA-2102
Summary
update_apps_cdn_build_metadataFastlane action that updates metadata of an existing build on the Apps CDN without re-uploading the filePOST /wp/v2/sites/{site_id}/a8c_cdn_build/{post_id}) with JSON bodyvisibility(:internal/:external) via taxonomy term ID lookup, andpost_status(publish/draft)Context
The companion Studio PR uses this action in its
publish_releaselane.The existing
upload_build_to_apps_cdnaction cannot be used to change visibility because visibility is part of the dedup matching criteria in the CDN plugin — re-uploading with a different visibility creates a new build rather than updating the existing one.Note: The v1.1 API (
/rest/v1.1/sites/{site_id}/posts/{post_id}) returns 500 fora8c_cdn_buildcustom post types, which is why this action uses the WP v2 endpoint instead.Test plan
bundle exec rspec spec/update_apps_cdn_build_metadata_spec.rb— 13 examples, 0 failures)🤖 Generated with Claude Code