Skip to content

Ingest daily sea ice extent #259

Ingest daily sea ice extent

Ingest daily sea ice extent #259

Workflow file for this run

# workflow to update monthly ocean temps
on:
# check at 9am AEST every day of the month
schedule:
- cron: '0 23 * * *'
workflow_dispatch:
name: Ingest daily sea ice extent
jobs:
ingest:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: r-lib/actions/setup-r@v2
with:
r-version: renv
# - uses: r-lib/actions/setup-pandoc@v2
- name: Install Linux system dependencies
run: |
sudo apt update
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libssl-dev
sudo apt-get install libharfbuzz-dev libfribidi-dev
- name: Restore packages with renv
uses: r-lib/actions/setup-renv@v2
# sets env.DAILY_IS_STALE=TRUE if new obs are available
- name: Check if update is required
id: check-update
run: Rscript R/check.r
# analysis sets env.DAILY_UPDATED=TRUE and end.DAILY_RUN_END=...
# when it successfully runs
# (R puts out uppercase strings for env vars, not actual bools)
- name: Run the analysis
if: env.DAILY_IS_STALE == 'TRUE'
run: Rscript R/ingest.r
- name: Print analysis script vars
run: echo $DAILY_UPDATED && echo $DAILY_RUN_END
# commit and push
- name: Commit and push updated results
if: env.DAILY_UPDATED == 'TRUE'
run: |
git config --local user.name actions-user
git config --local user.email "[email protected]"
git add data/*.csv
git diff-index --quiet HEAD || git commit -m "Ingest new results via GitHub Actions"
git push
# make a release if there's new data
- name: Publish release
if: env.DAILY_UPDATED == 'TRUE'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "v$(date +'%Y-%m-%d')" \
--repo="$GITHUB_REPOSITORY" \
--title="Daily sea ice extent: v$(date +'%Y-%m-%d')" \
--generate-notes
- name: Update Slack
uses: slackapi/[email protected]
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
payload: |
{
"event_type": "${{ github.event_name }}",
"run_end": "${{ env.DAILY_RUN_END }}",
"outcome_emoji": "${{ (env.DAILY_IS_STALE == 'FALSE') && '⏰' || (env.DAILY_UPDATED == 'TRUE') && '✅' || '❓' }}",
"outcome_long": "${{ (env.DAILY_IS_STALE == 'FALSE') && 'Update skipped (no new obs)' || (env.DAILY_UPDATED == 'TRUE') && 'New observations added!' || 'Workflow successfully executed, but the analysis script did not sign off properly. Something may not be right—this should be followed up.' }}",
"workflow_name": "Sea ice tracker: daily ingest"
}