-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3797 from department-of-veterans-affairs/db/fetch…
…-release-notes What's new: Automate updating release notes
- Loading branch information
Showing
11 changed files
with
5,350 additions
and
444 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{% comment %} | ||
Capture linebreaks before headings (to add another linebreak which fixes an issue where the headings are incorrectly nested within a list) | ||
{% endcomment %} | ||
{% assign reLineBreakBeforeHeader = '(\r\n)#' %} | ||
|
||
{% comment %} | ||
Capture github URL (to convert to markdown-type link) | ||
{% endcomment %} | ||
{% assign reGithubUrl = '(https?:\/\/(www\.)?github\.com(?:\/.*)?)' %} | ||
|
||
{% comment %} | ||
Capture any issue numbers in titles (to make them links) | ||
{% endcomment %} | ||
{% assign reIssueNumbersInTitle = '(#(\d+))' %} | ||
|
||
{% comment %} | ||
Capture PR number from URL (to create a link to the PR) | ||
{% endcomment %} | ||
{% assign rePrUrl = '\[https?:\/\/(www\.)?github\.com(?:\/.*)?pull\/(\d+)\s?\]' %} | ||
|
||
{% comment %} | ||
Capture h2-h5 headings (to +1 heading level so the HTML stays semantically structured with our page) | ||
{% endcomment %} | ||
{% assign reHeadingLevels = '(#{2,6})\s' %} | ||
|
||
{% comment %} | ||
Capture github usernames (to make a link to user profile) | ||
{% endcomment %} | ||
{% assign reUsernames = 'by\s(@(\S+))\s' %} | ||
|
||
{% comment %} | ||
Trim number of releases to show | ||
{% endcomment %} | ||
{% assign recentReleases = include.json | slice: 0, include.num_recent_releases %} | ||
|
||
{% for release in recentReleases %} | ||
<va-card class="vads-u-margin-bottom--2"> | ||
<span class="usa-label">{{ release.name }}</span> | ||
<div class="vads-u-font-size--xl vads-u-font-weight--bold vads-u-font-family--serif">{{ release.published_at | date: "%B %-d, %Y" }}</div> | ||
{{ release.body | ||
| regexreplace: reLineBreakBeforeHeader, '\1\1#' | ||
| regexreplace: reGithubUrl, '[\1](\1)' | ||
| regexreplace: reIssueNumbersInTitle, '[\1](https:/github.com/department-of-veterans-affairs/vets-design-system-documentation/issues/\2)' | ||
| regexreplace: rePrUrl, '[\#\2]' | ||
| regexreplace: reHeadingLevels, '\1# ' | ||
| regexreplace: reUsernames, 'by [\1](https://github.com/\2) ' | ||
| markdownify | ||
}} | ||
</va-card> | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require 'json' | ||
require 'open-uri' | ||
|
||
module Jekyll_Get_Json | ||
class Generator < Jekyll::Generator | ||
safe true | ||
priority :highest | ||
|
||
def get_final_url(url) | ||
if url.start_with? "https://api.github.com/" | ||
access_token = ENV['GITHUB_ACCESS_TOKEN'] | ||
if access_token | ||
return "#{url}?access_token=#{access_token}" | ||
end | ||
end | ||
url | ||
end | ||
|
||
def load_json(site, feed) | ||
name = feed['name'] | ||
url = feed['json'] | ||
path = "json_data_cache/#{name}.json" | ||
if not File.exist?(path) | ||
FileUtils.mkpath File.dirname(path) | ||
print "* Caching #{url}\n".green | ||
print " in " | ||
print "#{path}\n".cyan | ||
githubJekyllCache = URI(get_final_url(url)).open | ||
data = JSON.load(githubJekyllCache) | ||
File.open(path, 'wb') do |file| | ||
file << JSON.pretty_generate(data) | ||
end | ||
end | ||
cacheJSON = File.open(path) | ||
site.data[name] = JSON.load(cacheJSON) | ||
end | ||
|
||
def generate(site) | ||
config = site.config['github_releases'] | ||
if !config | ||
return | ||
end | ||
if !config.kind_of?(Array) | ||
config = [config] | ||
end | ||
config.each do |feed| | ||
url = feed['json'] | ||
begin | ||
load_json(site, feed) | ||
rescue => e | ||
print "jekyll_get: error fetching #{url}: #{e}\n".red | ||
next | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'uri' | ||
|
||
module VADS | ||
|
||
def regexreplace(input, regex, replacement = '') | ||
input.to_s.gsub(Regexp.new(regex), replacement.to_s) | ||
end | ||
end | ||
|
||
Liquid::Template.register_filter(VADS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters