Skip to content

Commit

Permalink
use date parsing utilities to minimize metadata block (#30)
Browse files Browse the repository at this point in the history
* use date parsing utilities to minimize metadata block

* use a gnu compatible invocation of sed

* export the variable

* try using step outputs
  • Loading branch information
chrisfenner authored Aug 15, 2022
1 parent 38654d4 commit 8389d1e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ runs:
's/^---$/\\newpage/g;1s/\\newpage/---/g'
${{ inputs.input-md }}
shell: sh
# Grab the date from the front matter and generate the full date and year.
- run: |
DATE=$(grep date: ${{ inputs.input-md }} | head -n 1 | cut -d ' ' -f 2)
YEAR=$(date --date=$DATE +%Y)
echo "::set-output name=year::$YEAR"
DATE_ENGLISH=$(date --date=$DATE "+%B %-d, %Y")
echo "::set-output name=date-english::$DATE_ENGLISH"
shell: bash
id: date
- run: >
pandoc
--embed-resources
Expand All @@ -51,6 +60,8 @@ runs:
--toc
--variable=block-headings
--variable=table-use-row-colors
--metadata=date-english:"${{ steps.date.outputs.date-english }}"
--metadata=year:"${{ steps.date.outputs.year }}"
--metadata=titlepage:true
--metadata=titlepage-background:/resources/img/cover.png
--metadata=logo:/resources/img/tcg.png
Expand Down
4 changes: 1 addition & 3 deletions sample1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
title: "Lorem Ipsum Platform Dolor Sit Amet Profile for TPM 2.0"
version: 0.1
revision: 196
date-english: August 11, 2022
date: 8/11/2022
year: 2022
date: 2022/8/2
type: SPECIFICATION
status: DRAFT
lot: true
Expand Down
2 changes: 0 additions & 2 deletions sample2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
title: "Important TCG Document"
version: 1.0
revision: 3
date-english: August 11, 2022
date: 8/11/2022
year: 2022
type: SPECIFICATION
status: PUBLISHED
lof: true
Expand Down

0 comments on commit 8389d1e

Please sign in to comment.