Skip to content

sunp-generate-graphs #1374

sunp-generate-graphs

sunp-generate-graphs #1374

name: sunp-generate-graphs
# Controls when the action will run.
on:
schedule:
- cron: '00 06 * * *'
workflow_dispatch:
workflow_run:
workflows: ["Generate Graphs"]
types:
- completed
jobs:
generate-graphs:
runs-on: ubuntu-latest
# Wrap the job in a strategy matrix for retries
strategy:
matrix:
max-retries: [0, 1, 2] # Adjust the number of retries as needed
# Load repo and install R
steps:
- name: Checkout with sunp-generate-graphs branch
uses: actions/checkout@v2
with:
ref: sunp-generate-graphs
fetch-depth: 1
- name: Set Up R
uses: r-lib/actions/setup-r@v2
- name: Install packages
run: |
R -e 'install.packages("lubridate")'
R -e 'install.packages("dplyr")'
- name: Run R Script
run: Rscript sunp-generate-graphs.R
# Commit files ,and push
- name: Commit files
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add sunpMetDataFigures_$(date '+%Y-%m-%d').pdf sunpWaterQualityDataFigures_$(date '+%Y-%m-%d').pdf
git commit -m "sunp-generate-graphs-$(date '+%Y-%m-%d')"
git branch sunp-graphs
git push --force origin sunp-graphs
# Check action status. If failure, send email to notify administrators
send-mail:
needs: generate-graphs
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
runs-on: ubuntu-latest
steps:
- name: Send mail
if: ${{ failure() }}
uses: dawidd6/action-send-mail@v2
with:
# mail server settings
server_address: smtp.gmail.com
server_port: 465
# user credentials
username: ${{ secrets.EMAIL_USERNAME }}
password: ${{ secrets.EMAIL_PASSWORD }}
# email subject
subject: ${{ github.job }} job of ${{ github.repository }} has ${{ job.status }}
# email body as text
body: |
${{ github.job }} job in worflow ${{ github.workflow }} of ${{ github.repository }} has ${{ job.status }}
The workflow link is https://github.com/FLARE-forecast/SUNP-data/actions/runs/${{ github.run_id }}
# comma-separated string, send email to
to: [email protected], [email protected]
# from email name
from: FLARE