-
Notifications
You must be signed in to change notification settings - Fork 1
83 lines (67 loc) · 2.66 KB
/
workflow.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
# Triggered on push and pull request events
on:
push:
pull_request:
schedule:
# every Tuesday (2) at 15:00 and 18:00 UTC
- cron: "0 15,18 * * 2"
# Name of the workflow => usethis::use_github_actions_badge("CI-CD-BUILD-DATA")
name: CI-CD-BUILD-DATA
jobs:
CI-CD:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
strategy:
# We keep a matrix for convenience, but we would typically just run on one
# single OS and R version, aligned with the target deployment environment
matrix:
config:
- {os: ubuntu-latest, r: '4.2.1'}
env:
# Access token for GitHub
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
# Preserve package sources for informative references in case of errors
R_KEEP_PKG_SOURCE: yes
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Pandoc
uses: r-lib/actions/setup-pandoc@v2
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
# Enable RStudio Package Manager to speed up package installation
use-public-rspm: true
- name: Activate renv and restore packages with cache
uses: r-lib/actions/setup-renv@v2
- name: Fetch and rebuild latest BAG data
if: github.event_name == 'schedule'
run: |
pkgload::load_all(export_all = TRUE, helpers = FALSE, attach_testthat = FALSE)
build_data()
shell: Rscript {0}
- name: Install R CMD check
run: install.packages("rcmdcheck")
shell: Rscript {0}
- name: Check package
uses: r-lib/actions/check-r-package@v2
- name: Commit and push updated BAG data
if: github.event_name == 'schedule'
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git add inst/bag_data/\*
git commit -m "Update BAG data" || echo "No changes to commit"
git pull --ff-only
git push origin
- name: Deploy to shinyapps.io
# Continuous deployment only for pushes to the main / master branch
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
env:
SHINYAPPS_ACCOUNT: ${{ secrets.SHINYAPPS_ACCOUNT }}
SHINYAPPS_TOKEN: ${{ secrets.SHINYAPPS_TOKEN }}
SHINYAPPS_SECRET: ${{ secrets.SHINYAPPS_SECRET }}
run: Rscript deploy/deploy-shinyapps.R