Render and Save PDF #15
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: # Allow to run manually from Actions tab | |
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 }} | |
GITHUB_PAT: ${{ secrets.GH_PAT }} | |
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" && \ | |
printf "\n- [Usage report for $ym](reports/$outname)" >> "aws-usage-report/README.md" | |
git config --local user.name "$GITHUB_ACTOR" | |
git config --local user.email "[email protected]" | |
git add "$outdir/$outname" "aws-usage-report/README.md" && git commit -m "Render report $ym" || echo "No changes to commit" | |
git push origin || echo "No changes to commit" |