-
Notifications
You must be signed in to change notification settings - Fork 14
154 lines (132 loc) · 4.51 KB
/
prepare_connect.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
147
148
149
150
151
152
153
154
---
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
name: Prepare Connect Deployment
env:
RENV_PATHS_ROOT: ~/.local/share/renv
BRANCH_DEPLOY: bot/deploy
PUSH_ON_BRANCH: main
jobs:
prepare-deployments:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
SHA: ${{ github.sha }}
steps:
- name: Setup system dependencies
run: >
sudo apt-get update && sudo apt-get install --yes
libcurl4-openssl-dev libsodium-dev
- name: Checkout repository
uses: actions/checkout@v3
- name: Declare some variables
id: vars
shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Install R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- 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: Install renv and box
run: install.packages(c("renv", "box"))
shell: Rscript {0}
- name: Setup git config
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
- name: Fetch branch if exists
continue-on-error: true
run: |
git fetch origin $BRANCH_DEPLOY
- name: Checkout branch and cleanup (setup orphan if no branch exists)
run: |
if [ `git rev-parse --verify origin/$BRANCH_DEPLOY 2>/dev/null` ]
then
git checkout origin/$BRANCH_DEPLOY -b $BRANCH_DEPLOY
else
git switch --orphan $BRANCH_DEPLOY
fi
- name: Checkout Apps
run: |
# Remove directories if they exist
[ ! -d "analytics" ] || git rm -rf analytics
[ ! -d "instrumentation" ] || git rm -rf instrumentation
[ ! -d "plumber_rest_api" ] || git rm -rf plumber_rest_api
# check out recent versions
git checkout ${{ github.sha }} -- inst/examples/app/analytics
git checkout ${{ github.sha }} -- inst/examples/app/instrumentation
git checkout ${{ github.sha }} -- plumber_rest_api
# move to correct directory (root)
git mv inst/examples/app/analytics analytics
git mv inst/examples/app/instrumentation instrumentation
# add changes
git add analytics
git add instrumentation
git add plumber_rest_api
- name: Prepare Analytics App
if : always()
shell: Rscript {0}
run: |
setwd("analytics")
renv::init(bare = TRUE)
renv::install(paste0("appsilon/shiny.telemetry@", Sys.getenv("SHA")))
renv::install("MASS")
renv::install()
renv::snapshot()
renv::install("rsconnect")
rsconnect::writeManifest()
- name: Prepare Instrumentation App
if : always()
shell: Rscript {0}
run: |
setwd("instrumentation")
renv::init(bare = TRUE)
renv::install(paste0("appsilon/shiny.telemetry@", Sys.getenv("SHA")))
renv::install()
renv::snapshot()
renv::install("rsconnect")
rsconnect::writeManifest()
- name: Prepare Plumber API
if : always()
shell: Rscript {0}
run: |
setwd("plumber_rest_api")
renv::restore()
renv::install(paste0("appsilon/shiny.telemetry@", Sys.getenv("SHA")))
renv::snapshot()
renv::install("rsconnect")
rsconnect::writeManifest()
- name: Commit changes
if: ${{ github.ref_name == env.PUSH_ON_BRANCH }}
id: commit-changes
run: |
git add instrumentation/manifest.json
git add instrumentation/renv.lock
git add instrumentation/renv
git add instrumentation/.Rprofile
git add analytics/manifest.json
git add analytics/renv.lock
git add analytics/renv
git add analytics/.Rprofile
git add plumber_rest_api/manifest.json
git commit -m "Update deployed apps @${{ env.sha_short }}"
git status
git describe --all
git log
- name: Push to branch
if: ${{ github.ref_name == env.PUSH_ON_BRANCH }}
id: push-changes
run: |
git push origin $BRANCH_DEPLOY