Skip to content

Instantly share code, notes, and snippets.

@yucao24hours
Last active July 2, 2020 02:55
Show Gist options
  • Save yucao24hours/12349a063a7d6e9f2ad72d91eeb0f925 to your computer and use it in GitHub Desktop.
Save yucao24hours/12349a063a7d6e9f2ad72d91eeb0f925 to your computer and use it in GitHub Desktop.
Get .circleci/config.yml in each repository entire my company's org (to migrate CircleCI to GitHub Actions)
require 'octokit'
client = Octokit::Client.new(access_token: 'your_personal_access_token')
client.auto_paginate = true
File.open('configs.md', 'w') do |file|
repos = client.org_repos('awesome_org_name')
repos.each.with_index(1) do |repo, index|
puts "#{index}: #{repo[:name]}"
begin
content = client.contents(repo[:full_name], path: '.circleci/config.yml')
file.puts "- #{content[:html_url]}" # Because I wanna create url list of Markdown
rescue Octokit::NotFound
next
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment