Skip to content

Commit 966f94d

Browse files
bdougieDamon Maneicedamaneice
authoredJul 9, 2020
Damaneice main (#12)
* Add script to create a README file * add new issue template * add readme workflow * update action job name Co-authored-by: Damon Maneice <damaneice@github.com> Co-authored-by: Damon Maneice <damaneice@gmail.com>
1 parent 511d59f commit 966f94d

File tree

7 files changed

+163
-57
lines changed

7 files changed

+163
-57
lines changed
 

‎.github/ISSUE_TEMPLATE/add-handle.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: Add handle
3+
about: Add handle
4+
title: Add handle [handle]
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
### handle
11+
* link 1
12+
* link 2

‎.github/workflows/photos.yml

-14
This file was deleted.

‎.github/workflows/readme.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Readme
2+
3+
on:
4+
issues:
5+
types: [opened, edited]
6+
7+
jobs:
8+
readme:
9+
if: startsWith(${{ github.event.issue.title }}, "Add handle")
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
ref: ${{ github.head_ref }}
15+
- run: 'echo "${{ github.event.issue.body }}" > temp.txt'
16+
- name: create-readme
17+
uses: ./action
18+
- run: rm temp.txt
19+
- name: Create Pull Request
20+
uses: peter-evans/create-pull-request@v2
21+
with:
22+
commit-message: ${{ github.event.issue.title }}
23+
title: ${{ github.event.issue.title }}
24+
body: |
25+
Closes #${{ github.event.issue.number }}
26+
labels: automated pr
27+
branch: add-new-developer-${{ github.event.issue.number }}

‎action/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ WORKDIR /usr/src/app
66

77
COPY . .
88

9-
CMD ["ruby", "./action/update-photos.rb"]
9+
CMD ["ruby", "./action/create-readme.rb"]
1010
#CMD ["ls"]

‎action/create-readme.rb

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/env ruby
2+
#/ Usage: ./action/update-photos
3+
#/ Update the local README photo wall to reflect the current developers listed in
4+
# bdougie/awesome-black-developers.
5+
require "yaml"
6+
7+
class Readme
8+
DEFAULT_README = "README.md"
9+
10+
def initialize(filename: DEFAULT_README)
11+
@filename = filename
12+
@developers = read_developer_yaml.merge(read_temp_file)
13+
end
14+
15+
def read_developer_yaml
16+
file = File.open('developers.yaml')
17+
file_data = file.read
18+
file.close
19+
YAML::load(file_data)
20+
end
21+
22+
def read_temp_file
23+
file = File.open('temp.txt')
24+
handle = ""
25+
links = []
26+
file_data = file.readlines.each_with_index.map do |line, index|
27+
if index == 0
28+
handle =line.gsub("#", "").strip
29+
else
30+
if !line.nil? && !line.strip.empty?
31+
links.push(line.gsub("*", "").strip)
32+
end
33+
end
34+
end
35+
{handle => links}
36+
end
37+
38+
def update_developer_yaml
39+
yaml = @developers.to_yaml
40+
File.write('developers.yaml', yaml)
41+
end
42+
43+
def preview
44+
[
45+
"# Awesome Black Developers [![Awesome](https://awesome.re/badge.svg)](https://awesome.re)",
46+
"> Talks, blog posts, and interviews amplifying the voices of Black developers on GitHub because #BlackLivesMatter",
47+
build_photo_grid(@developers),
48+
build_developer_list(@developers),
49+
"## 💅🏾 Contributing",
50+
"Additional suggestions are welcomed! Check out [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.",
51+
"(NOTE: If you're a developer listed on here who would like to be removed, just open an issue or message me privately.)",
52+
"## 📖 License and attribution
53+
This list is available under the Creative Commons CC0 1.0 License, meaning you are free to use it for any purpose, commercial or non-commercial, without any attribution back to me (public domain). (If you ever want to reference me, find me here! [@bdougieYO](http://twitter.com/bdougieYO) But you are in no way required to do so.)"
54+
].join("\n\n")
55+
end
56+
57+
def save!
58+
update_developer_yaml
59+
File.write(@filename, preview)
60+
end
61+
end
62+
63+
def build_photo_grid(users)
64+
lines = []
65+
66+
users.map{|k, v| k}.each_slice(8) do |slice|
67+
header = slice.map { |e| handle_link(e) }.join(" | ").strip
68+
delimiter = slice.map { |e| "---" }.join(" | ")
69+
row = slice.map { |e| photo_link(e) }.join(" | ").strip
70+
71+
lines += [header, delimiter, row, ""]
72+
end
73+
74+
lines.join("\n")
75+
end
76+
77+
def build_developer_list(users)
78+
row = users.map do |handle, links|
79+
developer_row = []
80+
developer_row.push("### [@#{handle}](https://github.com/#{handle})")
81+
links.each do |link|
82+
developer_row.push(" * #{link}")
83+
end
84+
developer_row.join("\n")
85+
end
86+
row.join("\n\n")
87+
end
88+
89+
def handle_link(login)
90+
"[@#{login}](https://github.com/#{login})"
91+
end
92+
93+
def photo_link(login)
94+
"![@#{login}](https://avatars.githubusercontent.com/#{login}?s=100&v=1)"
95+
end
96+
97+
def update_readme(save: false)
98+
readme = Readme.new
99+
save ? readme.save! : (puts readme.preview)
100+
end
101+
102+
update_readme(save: true)
103+

‎action/update-photos.rb

-42
This file was deleted.

‎developers.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
aprilspeight:
3+
- Vogue and Code ([project](https://www.vogueandcode.com/))
4+
- My Career Transition Story ([video](https://www.youtube.com/watch?v=kHrm-O3Z4dA&feature=emb_title))
5+
bdougie:
6+
- Open Sauced ([project](https://github.com/open-sauced/open-sauced))
7+
- Your next open source contribution ([video](https://www.youtube.com/watch?v=UzI2Wdl3arE))
8+
dayhaysoos:
9+
- use-shopping-cart ([project](https://github.com/dayhaysoos/use-shopping-cart))
10+
- How to ask for help without feeling like a burden. ([blog](https://dayhaysoos.com/how-to-ask-for-help/))
11+
ifiokjr:
12+
- remirror ([project](https://github.com/remirror/remirror))
13+
- GitHub Sponsor page ([sponsor](https://github.com/sponsors/ifiokjr))
14+
m0nica:
15+
- ReactLadies ([community](https://www.reactladies.com/))
16+
- Personal Growth From Open-Source And Meetups With Monica Powell ([blog](https://egghead.io/podcasts/personal-growth-from-open-source-and-meetups-with-monica-powell))
17+
- Delete Your Code and Other Reflections from Coderetreat Day ([podcast](https://www.aboutmonica.com/blog/code-retreat-reflection))
18+
Prophen:
19+
- PopSchools ([project](https://github.com/PopSchools))
20+
- How I discovered my voice ([blog](https://medium.com/datadriveninvestor/0-how-i-discovered-my-voice-ea278b69839c))

0 commit comments

Comments
 (0)
Failed to load comments.