Skip to content

Instantly share code, notes, and snippets.

@sasasin
Last active May 24, 2022 06:16
Show Gist options
  • Save sasasin/add536ab05caabfbae1099089dd93908 to your computer and use it in GitHub Desktop.
Save sasasin/add536ab05caabfbae1099089dd93908 to your computer and use it in GitHub Desktop.
esa の外部公開ページを一括で非公開にするやつ
#!/usr/bin/env ruby
# 意図せず外部公開にしてたり、用が済んだのに外部公開のままにしてたり、
# そういう esa の外部公開ページを一括で非公開にするやつ
# 参考:
# https://docs.esa.io/posts/102
# https://github.com/esaio/esa-ruby
require 'esa'
# set esa team name.
# https://${ESA_TEAM_NAME}.esa.io
ESA_TEAM_NAME=ENV['ESA_TEAM_NAME']
# set esa personal access token.
# generate at https://${ESA_TEAM_NAME}.esa.io/user/applications
ESA_ACCESS_TOKEN=ENV['ESA_ACCESS_TOKEN']
client = Esa::Client.new(access_token: ESA_ACCESS_TOKEN, current_team: ESA_TEAM_NAME)
posts = client.posts(q: 'sharing:true', per_page: 100)
posts.body['posts'].each do |post|
puts post['url']
client.delete_sharing(post['number'])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment