Skip to content

Add update_apps_cdn_build_metadata action#701

Open
iangmaia wants to merge 4 commits intotrunkfrom
iangmaia/add-update-apps-cdn-build-metadata-action
Open

Add update_apps_cdn_build_metadata action#701
iangmaia wants to merge 4 commits intotrunkfrom
iangmaia/add-update-apps-cdn-build-metadata-action

Conversation

@iangmaia
Copy link
Contributor

@iangmaia iangmaia commented Mar 2, 2026

Fixes AINFRA-2102

Summary

  • Adds a new update_apps_cdn_build_metadata Fastlane action that updates metadata of an existing build on the Apps CDN without re-uploading the file
  • Uses the WP REST API v2 (POST /wp/v2/sites/{site_id}/a8c_cdn_build/{post_id}) with JSON body
  • Supports updating visibility (:internal / :external) via taxonomy term ID lookup, and post_status (publish / draft)
  • This enables a two-phase release flow: upload builds as drafts during finalize, then publish at release time

Context

The companion Studio PR uses this action in its publish_release lane.

The existing upload_build_to_apps_cdn action 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 for a8c_cdn_build custom post types, which is why this action uses the WP v2 endpoint instead.

Test plan

  • Unit tests added and passing (bundle exec rspec spec/update_apps_cdn_build_metadata_spec.rb — 13 examples, 0 failures)
  • Manual test: verified against the real CDN API that both visibility updates and post_status changes work correctly via the v2 endpoint

🤖 Generated with Claude Code

…sting CDN builds

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@iangmaia iangmaia self-assigned this Mar 2, 2026
@iangmaia iangmaia added the enhancement New feature or request label Mar 2, 2026
@iangmaia iangmaia requested a review from Copilot March 2, 2026 20:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_metadata Fastlane 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.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@iangmaia iangmaia requested review from AliSoftware and mokagio March 3, 2026 18:44
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>
Comment on lines +61 to +74
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants