-
Notifications
You must be signed in to change notification settings - Fork 7
146 lines (128 loc) · 4.93 KB
/
apps-deploy.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Deploy
on:
push:
branches:
- deploy**
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#onschedule
schedule:
- cron: "0 3 * * 1-5" # every work night (delayed 0 hrs)
repository_dispatch:
types:
- all
# Trigger with `shinycoreci::trigger_deploy()`
- deploy
jobs:
config:
uses: ./.github/workflows/apps-config.yml
deploy:
runs-on: ${{ matrix.config.os }}
name: "${{ matrix.config.type }} (${{ matrix.config.r }})"
needs: config
strategy:
fail-fast: false
matrix:
config:
- os: "${{ needs.config.outputs.ubuntu }}"
# Use `oldrel1` to avoid the bleeding edge when creating manifest files. Ex: `{MASS}` version can not be satisfied when bundling on R4.3 (2023-05-01)
r: "${{ needs.config.outputs.oldrel1 }}"
type: "shinyappsio"
account: "testing-apps"
server_name: "shinyapps.io"
cores: 5
retry: 3
# extra_app_text: ", apps = c('000-all', '000-manual', '300-bs-themer')"
- os: "${{ needs.config.outputs.ubuntu }}"
r: "${{ needs.config.outputs.oldrel1 }}"
type: "connect"
account: "barret"
server_name: "rsc.radixu.com"
server_url: "https://rsc.radixu.com/__api__"
cores: 1
retry: 3
# extra_app_text: ", apps = c('000-all', '000-manual', '300-bs-themer')"
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
# RSPM: ${{ matrix.config.rspm }}
steps:
- uses: actions/checkout@v4
name: GitHub Pull
- name: R Options
shell: bash
run: |
echo 'MAKEFLAGS=-j2' >> .Renviron
- name: Install R, shinycoreci, and shinyverse
timeout-minutes: 30 # Should be < 10 mins
uses: ./.github/internal/install-shinyverse
with:
r-version: ${{ matrix.config.r }}
cache-version: deploy-2-${{ needs.config.outputs.cache-version }}
# Perform as second step to make sure this version is installed
- name: Install shinycoreci from GitHub
shell: Rscript {0}
run: |
pak::pkg_install("rstudio/shinycoreci@${{ github.sha }}")
- name: Deploy Apps to Shinyapps.io
if: matrix.config.type == 'shinyappsio'
shell: Rscript {0}
run: |
rsconnect::setAccountInfo(
name = '${{ matrix.config.account }}',
token = '${{ secrets.SHINYAPPS_IO_TESTING_APPS_TOKEN }}',
secret = '${{ secrets.SHINYAPPS_IO_TESTING_APPS_SECRET }}'
)
shinycoreci::deploy_apps(
install = FALSE,
retry = ${{ matrix.config.retry }},
cores = ${{ matrix.config.cores }},
account = '${{ matrix.config.account }}',
server = '${{ matrix.config.server_name }}'
${{ matrix.config.extra_app_text }}
)
- name: Deploy Apps to Connect
if: matrix.config.type == 'connect'
shell: Rscript {0}
run: |
# Add server info
rsconnect::addServer(
url = '${{ matrix.config.server_url }}',
name = '${{ matrix.config.server_name }}'
)
# Add user info
rsconnect::connectApiUser(
'${{ matrix.config.account }}',
'${{ matrix.config.server_name }}',
apiKey = '${{ secrets.BARRET_CONNECT_API_KEY }}'
)
# Deploy
shinycoreci::deploy_apps(
install = FALSE,
retry = ${{ matrix.config.retry }},
cores = ${{ matrix.config.cores }},
account = '${{ matrix.config.account }}',
server = '${{ matrix.config.server_name }}'
${{ matrix.config.extra_app_text }}
)
# Make URLs public
shinycoreci::connect_set_public(
account = '${{ matrix.config.account }}',
server = '${{ matrix.config.server_name }}'
${{ matrix.config.extra_app_text }}
)
- name: Save Connect Urls to Disk
if: matrix.config.type == 'connect'
shell: Rscript {0}
run: |
source("inst/gha/data-connect-urls-update.R")
update_connect_urls(
account = '${{ matrix.config.account }}',
server = '${{ matrix.config.server_name }}'
)
- name: Push Connect Urls to Repo
if: matrix.config.type == 'connect'
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add ./R
git commit -m 'Generate Connect URLs (GitHub Actions)' || echo "No Connect URL changes to commit"
git push https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git HEAD:${{ github.ref }} || echo "No Connect URLs to push"