-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add infrastructure to render nasa and noaa reports
- Loading branch information
Showing
5 changed files
with
62 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,6 @@ jobs: | |
uses: quarto-dev/quarto-actions/setup@v2 | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
# To install LaTeX to build PDF book | ||
tinytex: true | ||
|
||
# From https://github.com/r-lib/actions/tree/v2-branch/setup-r | ||
- name: Setup R | ||
|
@@ -44,12 +41,16 @@ jobs: | |
run: | | ||
ym=$(Rscript -e 'cat(format(lubridate::floor_date(Sys.Date(), unit = "months") - 1, "%Y-%m"))') | ||
outdir="$REPORT_DIR/reports" | ||
outname="aws-usage-report_$ym.pdf" | ||
quarto render $REPORT_DIR/aws-usage-report.qmd -P "year_month:$ym" --output "$outname" | ||
mkdir -p "$outdir" && \ | ||
mv "$outname" "$outdir" && \ | ||
printf "\n- [Usage report for $ym](reports/$outname)" >> "$REPORT_DIR/README.md" | ||
for suffix in nasa noaa; do | ||
target_filename="aws-usage-report-${suffix}_$ym.pdf" | ||
quarto render "$REPORT_DIR/aws-usage-report-${suffix}.qmd" -P "year_month:$ym" --output "$target_filename" | ||
mkdir -p "$outdir" && \ | ||
mv "$target_filename" "$outdir" && \ | ||
Rscript _hub-usage-reporting/update-report-page.R --args "$ym" "$target_filename" | ||
done | ||
git config --local user.name "$GITHUB_ACTOR" | ||
git config --local user.email "[email protected]" | ||
git add "$outdir/$outname" "$REPORT_DIR/README.md" && git commit -m "Render report $ym" || echo "No changes to commit" | ||
git add "$outdir/aws-usage-report-*.pdf" "usage-reporting.qmd" && \ | ||
git commit -m "Render reports $ym" || echo "No changes to commit" | ||
git push origin || echo "No changes to commit" |
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,34 @@ | ||
args <- setdiff(commandArgs(TRUE), "--args") | ||
|
||
ym <- args[1] | ||
target_filename <- args[2] | ||
|
||
org <- sub(".+-((nasa)|(noaa))_.+\\.pdf", "\\1", target_filename) | ||
|
||
new_report_line <- sprintf( | ||
"- [Usage report for %s](_hub-usage-reporting/reports/%s)", | ||
ym, | ||
target_filename | ||
) | ||
|
||
lines <- readLines("usage-reporting.qmd") | ||
|
||
if (!any(grepl(target_filename, lines, fixed = TRUE))) { | ||
cat( | ||
sprintf( | ||
"Adding report %s to %s monthly reports", | ||
target_filename, | ||
toupper(org) | ||
) | ||
) | ||
# split on html comment marking end of org reports | ||
org_insert_line <- grep(sprintf("<!-- last-%s-report -->", org), lines) | ||
org_before <- lines[seq_len(org_insert_line - 1)] | ||
org_after <- lines[seq(org_insert_line, length(lines))] | ||
|
||
# recombine with new report at the end of the list | ||
outlines <- c(org_before, new_report_line, org_after) | ||
writeLines(outlines, "usage-reporting.qmd", sep = "\n") | ||
} else { | ||
cat(sprintf("No new report to add for %s\n", org)) | ||
} |
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