epiforecasts-timeseries's automated submission #2384
Workflow file for this run
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
name: Link to submission preview | |
on: | |
# Instead of pull_request to be able to post comments | |
pull_request_target: | |
branches: main | |
paths: | |
- 'data-processed/**' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.number }} | |
cancel-in-progress: true | |
jobs: | |
submission_preview: | |
runs-on: ubuntu-20.04 | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
install-r: false | |
use-public-rspm: true | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install libcurl4-openssl-dev | |
# This workflow cannot work with renv since we never check out the repo. | |
- name: Install R dependencies | |
run: | | |
install.packages('gh') | |
shell: Rscript {0} | |
- name: Post comment linking to preview shiny app | |
env: | |
PR_NUMBER: ${{ github.event.number }} | |
run: | | |
source("https://gist.github.com/Bisaloo/db50c50922dc5d8d71791fe210e625be/raw/9eff642b8f481f34de2671e940327645498f972f/link_preview_app.R") | |
try({ | |
links <- link_preview( | |
gh_repo = Sys.getenv("GITHUB_REPOSITORY"), | |
pr_number = Sys.getenv("PR_NUMBER"), | |
data_folder = "data-processed", | |
app_location = "https://forecasthub.shinyapps.io/covid19-forecast-hub-europe/" | |
) | |
message("Preview link:\n ", paste(links, collapse = "\n ")) | |
if (!is.null(links)) { | |
gh::gh( | |
"/repos/{gh_repo}/issues/{pr_number}/comments", | |
.method = "POST", | |
gh_repo = Sys.getenv("GITHUB_REPOSITORY"), | |
pr_number = Sys.getenv("PR_NUMBER"), | |
accept = "application/vnd.github.v3+json", | |
body = paste(c("Preview of submitted forecast:", links), collapse = "\n\n") | |
) | |
} | |
}, silent = TRUE) | |
shell: Rscript {0} |