Test6 #52
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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."); | |
| } |