Skip to content

Commit

Permalink
feat: update deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhav committed Nov 10, 2023
1 parent 88b442a commit 3bd5795
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Deploy Apps 🚀
on:
push:
branches:
- main
- 78_simplify_joinkeys@main # TODO: change this to `dev` in `deploy_dev.yaml` and `main` in `deploy_stable.yaml`
workflow_dispatch:
schedule:
- cron: "12 3 * * *"
Expand All @@ -16,7 +16,9 @@ concurrency:
env:
SHINYAPPSIO_ACCOUNT: genentech
APP_PREFIX: NEST
APP_SUFFIX: dev # TODO: change this to `dev` in `deploy_dev.yaml` and `stable` in `deploy_stable.yaml`
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
BRANCH: 78_simplify_joinkeys@main # TODO: change this to `dev` in `deploy_dev.yaml` and `main` in `deploy_stable.yaml`

jobs:
deploy:
Expand Down Expand Up @@ -44,19 +46,10 @@ jobs:
"python",
"safety",
]
channel: ["stable", "dev"]
steps:
- name: Checkout repo 🛎
uses: actions/checkout@v3

- name: Set channel related constants
run: |
if [ "${{ matrix.channel }}" = "stable" ]; then
echo "BRANCH_NAME=main" >> $GITHUB_ENV # TODO: Change the branch name to main
else
echo "BRANCH_NAME=dev" >> $GITHUB_ENV # TODO: Change the branch name to deval
fi
- name: Check if cypress test exists
id: find-cypress
run: |
Expand All @@ -81,7 +74,7 @@ jobs:
- name: Restore renv from cache
uses: actions/cache@v3
env:
CACHE_KEY: renv-${{ runner.arch }}-${{ runner.os }}-${{ matrix.directory }}-${{ matrix.channel }}
CACHE_KEY: renv-${{ runner.arch }}-${{ runner.os }}-${{ matrix.directory }}-${{ env.APP_SUFFIX }}
with:
path: ${{ matrix.directory }}/renv/library
key: ${{ env.CACHE_KEY }}-${{ hashFiles(format('{0}/renv.lock', matrix.directory)) }}
Expand All @@ -92,10 +85,9 @@ jobs:
run: |
setwd("${{ matrix.directory }}")
lockfile <- renv::lockfile_read()
pkg_name_structure <- ifelse("${{ matrix.channel }}" == "stable", "%s/%s@*release", "%s/%s")
for (package in lockfile$Packages) {
if (package$Source == "GitHub") {
renv::record(sprintf(pkg_name_structure, package$RemoteUsername, package$Package))
renv::record(paste0(package$RemoteUsername, package$Package)) # TODO: This installs packages form main branch, make necessary change for release version.
}
}
Expand Down Expand Up @@ -143,8 +135,8 @@ jobs:
)
rsconnect::deployApp(
appFiles = c("app.R"),
appName = rsconnect::generateAppName("${{ env.APP_PREFIX }}_${{ matrix.directory }}_${{ matrix.channel }}"),
appTitle = "${{ env.APP_PREFIX }}_${{ matrix.directory }}_${{ matrix.channel }}",
appName = rsconnect::generateAppName("${{ env.APP_PREFIX }}_${{ matrix.directory }}_${{ env.APP_SUFFIX }}"),
appTitle = "${{ env.APP_PREFIX }}_${{ matrix.directory }}_${{ env.APP_SUFFIX }}",
account = "${{ env.SHINYAPPSIO_ACCOUNT }}",
upload = TRUE,
logLevel = "normal",
Expand All @@ -153,17 +145,19 @@ jobs:
)
- name: Commit updated renv.lock file
continue-on-error: true
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git config --global --add safe.directory /__w/teal.gallery/teal.gallery
git fetch
git stash
git checkout ${{ env.BRANCH_NAME }}
git stash apply
git pull
git stash apply
git add ${{ matrix.directory }}/renv.lock
git add ${{ matrix.directory }}/renv/activate.R
if [ -n "$(git diff --staged)" ]; then
git add ${{ matrix.directory }}/renv.lock
git commit -m "[skip deploy] Update renv.lock file for ${{ matrix.directory }} app"
git push origin ${{ env.BRANCH_NAME }}
else
Expand Down

0 comments on commit 3bd5795

Please sign in to comment.