-
Notifications
You must be signed in to change notification settings - Fork 17
59 lines (53 loc) · 1.91 KB
/
submission_preview.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Link to submission preview
on:
pull_request_target:
branches: main
paths:
- 'data-processed/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
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.githubusercontent.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-scenario-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}