Skip to content

Commit

Permalink
Turn on GitHub action for whatsnew (dotnet#22616)
Browse files Browse the repository at this point in the history
- Add shell script, yml config and package for "what's new" package
- add the NuGet package with the latest tool
- Update the whatsnew.json file to include parameters for automatically updated the index.yml and toc.yml
- Update the TOC so that it has a single rolling list of articles (the action expects that)
  • Loading branch information
BillWagner authored Jun 25, 2021
1 parent 6aa1002 commit 0d998fa
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 19 deletions.
Binary file not shown.
30 changes: 30 additions & 0 deletions .github/workflows/dependencies/run-dotnet-whatsnew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -e

# This script runs the .NET CLI, invoking the what's new global tool
# $1 is the <github.repository_owner>
# $2 is the <github.repository>
# $3 is the savedir

declare -r STARTDATE=$(date "+%F" -d "$(date +'%Y-%m-01') -1 month");
declare -r ENDDATE=$(date "+%F" -d "$STARTDATE +1 month -1 day");

echo "From $STARTDATE to $ENDDATE"

while getopts o:r:s: option
do
case "${option}"
in
o) OWNER=${OPTARG};;
r) REPO=${OPTARG};;
s) SAVEDIR=${OPTARG};;
esac
done

dotnet whatsnew \
--owner $OWNER \
--repo $REPO \
--startdate $STARTDATE \
--enddate $ENDDATE \
--savedir $SAVEDIR
66 changes: 66 additions & 0 deletions .github/workflows/whats-new.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This is a basic workflow to help you get started with Actions

name: 'generate what''s new article'

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the default branch
schedule:
- cron: '0 0 1 * *' # The first of every month
workflow_dispatch:
inputs:
reason:
description: 'The reason for running the workflow'
required: true
default: 'Manual run'

env:
DOTNET_VERSION: '5.0.301' # set this to the dot net version to use
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "create-what-is-new"
create-what-is-new:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

# Runs a single command using the runners shell
- name: 'Print manual run reason'
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo 'Reason: ${{ github.event.inputs.reason }}'
# Print dotnet info
- name: Display .NET info
run: dotnet --info

# Install dotnet-whatsnew global tool
- name: Install dotnet-whatsnew tool
run: |
dotnet tool install --global --add-source ./.github/workflows/dependencies/ dotnet-whatsnew
# Run dotnet-whatsnew tool
- name: Generate what's new
id: dotnet-whatsnew
env:
GitHubKey: ${{ secrets.GITHUB_TOKEN }}
run: |
./.github/workflows/dependencies/run-dotnet-whatsnew.sh -o dotnet -r AspNetCore.Docs -s './aspnetcore/whats-new'
# Create the PR for the new article
- name: create-pull-request
uses: peter-evans/[email protected]
with:
title: 'What''s new article'
commit-message: 'Bot 🤖 generated "What''s new article"'
body: 'Automated creation of What''s new article.'
7 changes: 7 additions & 0 deletions .whatsnew.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"docLinkSettings": {
"linkFormat": "xref"
},
"navigationOptions": {
"maximumNumberOfArticles": 6,
"tocParentNode": "What's new",
"repoTocFolder": "aspnetcore/whats-new",
"indexParentNode": "Find ASP.NET Core docs updates",
"repoIndexFolder": "aspnetcore/whats-new"
},
"inclusionCriteria": {
"additionalMicrosoftOrgs": [
"ASP.NET"
Expand Down
32 changes: 13 additions & 19 deletions aspnetcore/whats-new/toc.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
items:
- name: What's new
href: index.yml
expanded: true
items:
- name: 2021
expanded: true
items:
- name: May
href: 2021-05.md
- name: April
href: 2021-04-01.md
- name: March
href: 2021-03.md
- name: February
href: 2021-02.md
- name: January
href: 2021-01.md
- name: 2020
expanded: true
items:
- name: December
href: 2020-12.md

- name: May 2021
href: 2021-05.md
- name: April 2021
href: 2021-04-01.md
- name: March 2021
href: 2021-03.md
- name: February 2021
href: 2021-02.md
- name: January 2021
href: 2021-01.md
- name: December 2021
href: 2020-12.md

0 comments on commit 0d998fa

Please sign in to comment.