Skip to content

Commit f15c998

Browse files
authored
Merge pull request #3797 from department-of-veterans-affairs/db/fetch-release-notes
What's new: Automate updating release notes
2 parents 529cf4a + 35a5438 commit f15c998

File tree

11 files changed

+5350
-444
lines changed

11 files changed

+5350
-444
lines changed

_config.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,13 @@ exclude:
9494
storybook_path: "http://localhost:8080"
9595
storybook_prod_uswds_path: "https://design.va.gov/storybook/?path=/docs/uswds"
9696
storybook_mobile_path: "https://department-of-veterans-affairs.github.io/va-mobile-library"
97+
98+
github_releases:
99+
- name: site_releases
100+
json: "https://api.github.com/repos/department-of-veterans-affairs/vets-design-system-documentation/releases"
101+
- name: component_library_releases
102+
json: "https://api.github.com/repos/department-of-veterans-affairs/component-library/releases"
103+
104+
figma_changelog_embed_url: https://embed.figma.com/proto/afurtw4iqQe6y4gXfNfkkk/VADS-Component-Library?page-id=14896%3A14785&node-id=14896-16876&viewport=550%2C221%2C1&scaling=contain&content-scaling=responsive&starting-point-node-id=14896%3A16876&embed-host=share&footer=false
105+
106+
figma_changelog_direct_url: https://embed.figma.com/design/afurtw4iqQe6y4gXfNfkkk/VADS-Component-Library?page-id=14896%3A14785&node-id=14896-16876&viewport=550%2C221%2C1&scaling=contain&content-scaling=responsive&starting-point-node-id=14896%3A16876&embed-host=share&footer=false

json_data_cache/component_library_releases.json

Lines changed: 1289 additions & 0 deletions
Large diffs are not rendered by default.

json_data_cache/site_releases.json

Lines changed: 3867 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"build": "gulp build",
99
"start": "yarn run build && bundle exec jekyll serve --baseurl ''",
10-
"watch": "yarn run build && bundle exec jekyll serve --baseurl '' --incremental"
10+
"watch": "yarn run build && bundle exec jekyll serve --baseurl '' --incremental",
11+
"update-releases": "rm -rf json_data_cache && yarn run build && bundle exec jekyll serve --baseurl ''"
1112
},
1213
"repository": {
1314
"type": "git",

src/_about/whats-new.md

Lines changed: 24 additions & 442 deletions
Large diffs are not rendered by default.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{% comment %}
2+
Capture linebreaks before headings (to add another linebreak which fixes an issue where the headings are incorrectly nested within a list)
3+
{% endcomment %}
4+
{% assign reLineBreakBeforeHeader = '(\r\n)#' %}
5+
6+
{% comment %}
7+
Capture github URL (to convert to markdown-type link)
8+
{% endcomment %}
9+
{% assign reGithubUrl = '(https?:\/\/(www\.)?github\.com(?:\/.*)?)' %}
10+
11+
{% comment %}
12+
Capture any issue numbers in titles (to make them links)
13+
{% endcomment %}
14+
{% assign reIssueNumbersInTitle = '(#(\d+))' %}
15+
16+
{% comment %}
17+
Capture PR number from URL (to create a link to the PR)
18+
{% endcomment %}
19+
{% assign rePrUrl = '\[https?:\/\/(www\.)?github\.com(?:\/.*)?pull\/(\d+)\s?\]' %}
20+
21+
{% comment %}
22+
Capture h2-h5 headings (to +1 heading level so the HTML stays semantically structured with our page)
23+
{% endcomment %}
24+
{% assign reHeadingLevels = '(#{2,6})\s' %}
25+
26+
{% comment %}
27+
Capture github usernames (to make a link to user profile)
28+
{% endcomment %}
29+
{% assign reUsernames = 'by\s(@(\S+))\s' %}
30+
31+
{% comment %}
32+
Trim number of releases to show
33+
{% endcomment %}
34+
{% assign recentReleases = include.json | slice: 0, include.num_recent_releases %}
35+
36+
{% for release in recentReleases %}
37+
<va-card class="vads-u-margin-bottom--2">
38+
<span class="usa-label">{{ release.name }}</span>
39+
<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>
40+
{{ release.body
41+
| regexreplace: reLineBreakBeforeHeader, '\1\1#'
42+
| regexreplace: reGithubUrl, '[\1](\1)'
43+
| regexreplace: reIssueNumbersInTitle, '[\1](https:/github.com/department-of-veterans-affairs/vets-design-system-documentation/issues/\2)'
44+
| regexreplace: rePrUrl, '[\#\2]'
45+
| regexreplace: reHeadingLevels, '\1# '
46+
| regexreplace: reUsernames, 'by [\1](https://github.com/\2) '
47+
| markdownify
48+
}}
49+
</va-card>
50+
{% endfor %}

src/_includes/_site-on-this-page.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
</dt>
77
{% for item in page.anchors %}
88
<dd role="definition" class="site-on-this-page__definition">
9-
<a class="site-on-this-page__link" href="#{{ item.anchor | downcase | replace: " ", "-" | replace: "’", "" | replace: "'", "" | replace: ",", "" }}">
9+
<a class="site-on-this-page__link" href="#{{ item.anchor | downcase | replace: " ", "-" | replace: "’" , "" |
10+
replace: "'" , "" | replace: "," , "" | replace: "." , "" }}">
1011
<i aria-hidden="true" class="fas fa-arrow-down"></i>
1112
{{ item.anchor }}
1213
</a>

src/_layouts/default.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@
3333
</div>
3434
</div>
3535
</main>
36+
{% elsif page.sidebar %}
37+
{% include _site-content-nav.html %}
38+
<div class="site-content__content">
39+
<main id="main-content" class="site-l-content-wrapper--sidebar large-screen:vads-u-margin-top--neg2">
40+
<aside class="main-content__sidebar">
41+
{% include _site-on-this-page.html %}
42+
</aside>
43+
<div class="main-content__content">
44+
{{ content }}
45+
</div>
46+
</main>
47+
</div>
3648
{% else %}
3749
{% include _site-content-nav.html %}
3850
<div class="site-content__content">

src/_plugins/jekyll_get_json.rb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
require 'json'
2+
require 'open-uri'
3+
4+
module Jekyll_Get_Json
5+
class Generator < Jekyll::Generator
6+
safe true
7+
priority :highest
8+
9+
def get_final_url(url)
10+
if url.start_with? "https://api.github.com/"
11+
access_token = ENV['GITHUB_ACCESS_TOKEN']
12+
if access_token
13+
return "#{url}?access_token=#{access_token}"
14+
end
15+
end
16+
url
17+
end
18+
19+
def load_json(site, feed)
20+
name = feed['name']
21+
url = feed['json']
22+
path = "json_data_cache/#{name}.json"
23+
if not File.exist?(path)
24+
FileUtils.mkpath File.dirname(path)
25+
print "* Caching #{url}\n".green
26+
print " in "
27+
print "#{path}\n".cyan
28+
githubJekyllCache = URI(get_final_url(url)).open
29+
data = JSON.load(githubJekyllCache)
30+
File.open(path, 'wb') do |file|
31+
file << JSON.pretty_generate(data)
32+
end
33+
end
34+
cacheJSON = File.open(path)
35+
site.data[name] = JSON.load(cacheJSON)
36+
end
37+
38+
def generate(site)
39+
config = site.config['github_releases']
40+
if !config
41+
return
42+
end
43+
if !config.kind_of?(Array)
44+
config = [config]
45+
end
46+
config.each do |feed|
47+
url = feed['json']
48+
begin
49+
load_json(site, feed)
50+
rescue => e
51+
print "jekyll_get: error fetching #{url}: #{e}\n".red
52+
next
53+
end
54+
end
55+
end
56+
end
57+
end

src/_plugins/vads.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require 'uri'
2+
3+
module VADS
4+
5+
def regexreplace(input, regex, replacement = '')
6+
input.to_s.gsub(Regexp.new(regex), replacement.to_s)
7+
end
8+
end
9+
10+
Liquid::Template.register_filter(VADS)

0 commit comments

Comments
 (0)