Render and Save PDF #3
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
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '45 1 1 * *' # 1:45 am on 1st day of every month | |
name: Render and Save PDF | |
jobs: | |
build-deploy: | |
runs-on: ubuntu-latest | |
env: | |
GRAFANA_TOKEN: ${{ secrets.GRAFANA_TOKEN }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up Quarto | |
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 | |
uses: r-lib/actions/setup-r@v2 | |
- name: Setup R dependencies | |
uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
cache-version: 2 | |
working-directory: aws-usage-report | |
- name: Render qmd file and Commit PDF report | |
run: | | |
ym=$(Rscript -e 'cat(format(lubridate::floor_date(Sys.Date(), unit = "months") - 1, "%Y-%m"))') | |
outdir="aws-usage-report/reports" | |
outname="aws-usage-report_$ym.pdf" | |
quarto render aws-usage-report/aws-usage-report.qmd -P year_month:$ym --output "$outname" | |
mkdir -p $outdir && mv "$outname" $outdir | |
git config --local user.name "$GITHUB_ACTOR" | |
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" | |
git commit $outdir/$outname -m 'Render report $ym' || echo "No changes to commit" | |
git push origin || echo "No changes to commit" |