-
-
Save iruca3/5507be6135157ee19e61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'esa' | |
access_token = 'アクセストークン' | |
team = 'チーム名' | |
old_bucket_name = '旧バケット名' | |
new_bucket_name = '新バケット名' | |
client = Esa::Client.new(access_token: access_token, current_team: team) | |
page = 1 | |
while true | |
posts = client.posts(q: old_bucket_name, page: page) | |
body = posts.body | |
body['posts'].each do |post| | |
new_body = post['body_md'].gsub(old_bucket_name, new_bucket_name) | |
client.update_post(post['number'], name: post['name'], body_md: new_body, updated_by: 'esa_bot') | |
puts "UPDATED: #{post['number']}" | |
sleep 1 | |
end | |
break unless body['next_page'] | |
page += 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment