-
Notifications
You must be signed in to change notification settings - Fork 9
46 lines (42 loc) · 1.59 KB
/
shiny-pr-3-cleanup.yaml
File metadata and controls
46 lines (42 loc) · 1.59 KB
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
# Workflow for cleaning up deployed Shiny apps after PR closure
name: Shiny PR 3 Cleanup
on:
pull_request_target:
types: [closed]
jobs:
cleanup-pr:
runs-on: ubuntu-24.04
if: contains(github.event.pull_request.labels.*.name, 'DEPLOY')
permissions:
pull-requests: write
steps:
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
- name: Delete app
env:
SHINY_APP_NAME: ${{ vars.SHINY_APP_NAME }}_PR_${{ github.event.pull_request.number }}
run: |
install.packages("rsconnect")
rsconnect::setAccountInfo("${{ vars.SHINY_ACCOUNT }}", "${{ secrets.SHINY_TOKEN }}", "${{ secrets.SHINY_SECRET }}")
rsconnect::terminateApp(appName = "${{ env.SHINY_APP_NAME }}", account = "${{ vars.SHINY_ACCOUNT }}")
rsconnect::purgeApp(appName = "${{ env.SHINY_APP_NAME }}", account = "${{ vars.SHINY_ACCOUNT }}")
shell: Rscript {0}
- name: Remove DEPLOY label
if: always() # even if previous step fails
uses: actions/github-script@v7
with:
script: |
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'DEPLOY'
});
} catch (e) {
console.log("Label `DEPLOY` not found, skipping removal.");
}