-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What's new: Automate updating release notes #3797
Merged
+5,350
−444
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ea1fff9
What's new: Automate release notes updates
danbrady 41bbb56
Merge branch 'main' into db/fetch-release-notes
danbrady 292f5fd
Make links from issue numbers in titles
danbrady 850a953
Add comments and fix header in list bug
danbrady eaf918f
Update number of releases to display
danbrady 8ec1e99
Update iframe height
danbrady a3d809e
Update guidance title
danbrady 2d2e3a2
Merge branch 'main' into db/fetch-release-notes
danbrady e98fa78
Update releases
danbrady 9667db2
Merge branch 'db/fetch-release-notes' of github.com:department-of-vet…
danbrady a14c03c
Change cache directory
danbrady d9d74ba
Merge branch 'main' into db/fetch-release-notes
danbrady 35a5438
Bump releases
danbrady File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the script removes the json_data_cache folder and rebuilds it each time there's an update, maybe add that folder to the .gitignore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I went back and forth on this. I originally had it, but that means when everyone runs their local envs, it will fetch the JSON files. It also will fetch any time production is updated. Github does have a rate limit (not that I expect that we'd hit it), but think it's better to not have these requests until we're sure that's how we want it to operate. For now, I think we want to manually kick off this process when we deploy the package to vets-website. I think we should add this to the backlog to investigate further.