-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dangerfile
56 lines (47 loc) · 2.96 KB
/
Dangerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
is_next_issue = github.pr_labels.any? { |label| label.include? "next issue" }
# -----------------------------------------------------------------------------
# Uploading images
# -----------------------------------------------------------------------------
if is_next_issue
message(":camera: To add images to this issue, [upload them here](https://github.com/techworkersco/techworkersco.github.io/upload/#{github.branch_for_head}/img).")
message(":wastebasket: To **remove** images from this issue, [find them listed here](https://github.com/techworkersco/techworkersco.github.io/tree/#{github.branch_for_head}/img). Select an image, then click the trash icon.")
end
# -----------------------------------------------------------------------------
# All pull requests should be submitted to master branch
# -----------------------------------------------------------------------------
if github.branch_for_base != "master"
warn("Pull requests should be submitted to the `master` branch only.")
end
# -----------------------------------------------------------------------------
# Tips for auto-publishing
# -----------------------------------------------------------------------------
has_auto_publish_label = github.pr_labels.any? { |label| label.include? "auto-publish" }
if is_next_issue && !has_auto_publish_label
message(":bulb: Add the `auto-publish` label to [automatically publish this issue tomorrow morning](https://github.com/techworkersco/techworkersco.github.io/blob/master/.github/DOCUMENTATION.md#labels).")
end
# -----------------------------------------------------------------------------
# Reminder for writing a draft
# -----------------------------------------------------------------------------
is_adding_draft = !(git.added_files.grep(/_drafts/).empty?)
is_editing_draft = !(git.modified_files.grep(/_drafts/).empty?)
if is_editing_draft || is_adding_draft
fail("Looks like you are editing a draft. Drafts will not be published.")
end
# -----------------------------------------------------------------------------
# Verify Jekyll template
#
# Borrowed from: https://github.com/artsy/artsy.github.io/blob/master/Dangerfile
# -----------------------------------------------------------------------------
active_files = (git.modified_files + git.added_files).uniq
posts = active_files
.select { |file| file.start_with? '_posts/' }
.select { |file| file.end_with?('.md') }
posts.each do |filename|
file = File.read(filename)
if !(file.include?("<!--excerpt-->"))
fail("Missing excerpt tag `<!--excerpt-->`. Please add the excerpt tag where you'd like this post to break for the preview. ([docs here](https://github.com/techworkersco/techworkersco.github.io/blob/master/.github/DOCUMENTATION.md#issue-template))", file: filename)
end
if !(file.include?("{% include post_image.html %}"))
warn("**Header image not included in the markdown file!** Add `{% include post_image.html %}` where you would like to place the image.", file: filename)
end
end