Skip to content

Update vegmap shapefile download and metadata; add new functions and … #4200

Update vegmap shapefile download and metadata; add new functions and …

Update vegmap shapefile download and metadata; add new functions and … #4200

Workflow file for this run

# MIT License
# Copyright (c) 2021 Eli Lilly and Company
# Author: William Michael Landau (will.landau at gmail)
# Edited by Adam Wilson (adamw at buffalo)
# Written with help from public domain (CC0 1.0 Universal) workflow files by Jim Hester:
# * https://github.com/r-lib/actions/blob/master/examples/check-full.yaml
# * https://github.com/r-lib/actions/blob/master/examples/blogdown.yaml
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
on:
push:
branches:
- main
- master
- dev-adam-appeears
- dev-jiyeon
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # runs every Sunday at midnight UTC
# - cron: '0 0 * * *' # runs every day at midnight
# - cron: '0 */6 * * *' # run every 6th hour
name: targets
jobs:
targets:
runs-on: ubuntu-latest
container: adamwilsonlab/emma:latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
EARTHDATA_PASSWORD: ${{ secrets.EARTHDATA_PASSWORD }}
EARTHDATA_USER: ${{ secrets.EARTHDATA_USER }}
RENV_PATHS_ROOT: ~/.local/share/renv
ACTIONS_RUNNER_DEBUG: true
steps:
- uses: actions/checkout@v2
with:
ref: dev-adam-appeears
lfs: true
- name: Whitelist directory
run: git config --global --add safe.directory /__w/emma_envdata/emma_envdata
- name: Install system deps for keyring
run: |
apt-get update
apt-get install -y libsecret-1-0 libsecret-1-dev
- name: Install R Package Dependencies
run: |-
Rscript -e "questionr::qscan(list.files(pattern='*.R',recursive=T), load = TRUE, detail = TRUE)" # this scans all scripts and installs any needed packages
- name: Parse _targets.R
run: Rscript -e "parse('_targets.R')"
- name: Cache packages
uses: actions/cache@v3
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: ${{ runner.os }}-renv-
- name: Cache targets store
uses: actions/cache@v3
with:
path: _targets/
key: targets-${{ hashFiles('_targets.R', 'R/**') }}
restore-keys: targets-
- name: Run targets pipeline
run: |
Rscript -e "targets::tar_make()" 2>&1 | tee targets-output.log || echo "tar_make failed, see log above"
shell: bash
continue-on-error: true
- name: Export final data products to releases
if: github.ref == 'refs/heads/main'
run: |
# Load final targets and export to data/releases/
targets::tar_load_everything()
# Create releases directory
dir.create("data/releases", recursive = TRUE, showWarnings = FALSE)
# Export domain as gpkg (example - adjust to your actual target names)
if (exists("domain")) {
sf::st_write(
sf::st_as_sf(domain),
"data/releases/domain.gpkg",
delete_dsn = TRUE
)
}
# Add other final outputs here as needed
# Example: write.csv(final_data, "data/releases/final_data.csv")
shell: Rscript {0}
continue-on-error: true
- name: Upload to GitHub Releases
if: github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v1
with:
tag_name: latest
files: |
data/releases/*
body: |
Latest data products from targets pipeline
Updated: ${{ github.event.head_commit.timestamp }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare failure artifact
if: failure()
run: rm -rf .git .github
- name: Post failure artifact
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-results
path: .
- name: Create review PR on failure
if: failure() && github.event_name == 'push'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Create error log if it doesn't exist
if [ ! -f targets-output.log ]; then
echo "No targets-output.log file found. Pipeline may have failed during execution." > targets-output.log
fi
# Get last 100 lines of error
tail -100 targets-output.log > error-summary.txt
# Create branch
BRANCH="auto-fix-$(date +%s)"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH"
# Add error log
mkdir -p .github/workflow-logs
cp targets-output.log .github/workflow-logs/failure-$(date +%Y%m%d-%H%M%S).log
git add .github/workflow-logs/
git commit -m "Add workflow failure log for review" || true
git push origin "$BRANCH"
# Create PR (Copilot will auto-review it)
gh pr create \
--title "🚨 Targets workflow failed - Review needed" \
--body "## Workflow Failure
The targets pipeline failed. GitHub Copilot will review this PR.
### Error Summary
\`\`\`
$(cat error-summary.txt)
\`\`\`
### Full Log
See \`.github/workflow-logs/\` for complete output.
**Next steps:**
1. Review Copilot's suggestions in the PR
2. Apply fixes
3. Close this PR once resolved" \
--base main \
--head "$BRANCH" \
--label "bug,auto-generated"
- name: Comment on existing PR with status
if: always() && github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
STATUS="${{ steps.targets.outcome }}"
if [ "$STATUS" = "success" ]; then
EMOJI="✅"
MESSAGE="Targets workflow completed successfully!"
else
EMOJI="❌"
MESSAGE="Targets workflow failed. See logs below."
fi
if [ ! -f targets-output.log ]; then
echo "No targets-output.log file found. Pipeline completed without explicit log output." > targets-output.log
fi
gh pr comment ${{ github.event.pull_request.number }} --body "## $EMOJI Targets Workflow Result
$MESSAGE
<details>
<summary>Show last 50 lines of output</summary>
\`\`\`
$(tail -50 targets-output.log)
\`\`\`
</details>"