Skip to content

Commit

Permalink
Sketch out GH workflow for generating repos.md
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotsykes committed Feb 17, 2024
1 parent 509aa4e commit f67be28
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Docs
on: [push]

# Restrict to one CI run at a time, per branch. In progress runs are *not* cancelled, but pending runs are
# cancelled, except for the most recent: https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}


jobs:
repos.md:
runs-on: ubuntu-latest
steps:
- name: Setup Ruby
# Docs: https://github.com/ruby/setup-ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true # Runs bundle install and caches gems
ruby-version: .ruby-version

- name: Checkout code
uses: actions/checkout@v4

- name: Generate repos.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bin/get_project_data > repos.md

- name: Debug repos.md
run: cat repos.md

- name: Commit repos.md
run: echo "TODO Commit repos.md"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ GIT_LFS_SKIP_SMUDGE=1 git submodule add -b <DEFAULT_BRANCH> [email protected]:githu
Regenerate [`repos.md`](repos.md):

```bash
# Requires valid GITHUB_ACCESS_TOKEN
# Requires valid GITHUB_TOKEN
bin/get_project_data > repos.md

# OR, if GitHub GraphQL API v4 schema has changed, update cached copy of schema:
Expand Down
10 changes: 4 additions & 6 deletions bin/get_project_data
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
require 'rubygems'
require 'bundler/setup'



# https://developer.github.com/early-access/graphql/explorer/
# https://stackoverflow.com/questions/39666940/how-to-batch-github-graphql-api-queries

Expand All @@ -34,7 +32,7 @@ class Repo
def self.all
@repos ||= File.read('.gitmodules').scan(REPO_PATTERN).map do |login, name|
new(login: login, name: name)
end
end.sort_by(&:name)
end

def to_s
Expand All @@ -54,8 +52,8 @@ module GitHub

HTTP = GraphQL::Client::HTTP.new("https://api.github.com/graphql") do
def headers(context)
unless token = context[:access_token] || ENV['GITHUB_ACCESS_TOKEN']
# $ GITHUB_ACCESS_TOKEN=abc123
unless token = context[:access_token] || ENV['GITHUB_TOKEN']
# $ GITHUB_TOKEN=abc123
# https://help.github.com/articles/creating-an-access-token-for-command-line-use
# Get temporary access token from ~/.config/hub
fail 'Missing GitHub access token. Get temporary access token from ~/.config/hub'
Expand Down Expand Up @@ -83,7 +81,7 @@ module GitHub

def self.fetch_all
variables = {}
client_context = { access_token: ENV['GITHUB_ACCESS_TOKEN'] }
client_context = { access_token: ENV['GITHUB_TOKEN'] }

puts "# Real World Rails"
puts "\n"
Expand Down

0 comments on commit f67be28

Please sign in to comment.