Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: plotly/de-deploy@v2
- uses: plotly/de-deploy@main
with:
DE_HOST: ${{ secrets.DE_HOST }}
DE_USERNAME: ${{ secrets.DE_USERNAME }}
Expand All @@ -55,6 +55,7 @@ The inputs this action uses are:
| `create_redis` | `false` | None | True to create a Redis instance for the app. |
| `create_postgres` | `false` | None | True to create a Postgres instance for the app. |
| `create_persistent_filesystem` | `false` | None | True to create a persistent filesystem for the app. |
| `env_vars` | `false` | None | Environment variables to add. Separate multiple variables with a space. Example: `env_vars: "FOO=BAR FOO_SECRET=${{ secrets.FOO_SECRET }}"` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work without quotation marks?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the current design, no. Without string, it would not be possible to split them. But er cam change it

To make it more transparent/less error prone, we can do this:

name: Deploy to Dash Enterprise

on:
  push:
    branches:
      - main

jobs:
  deploy:
    name: 'Deploy to Dash Enterprise'
    runs-on: ubuntu-latest
    strategy:
      matrix:
        env_var:
          - name: "FOO"
            value: "BAR"
          - name: "FOO_SECRET"
            value: "${{ secrets.FOO_SECRET }}"

  

Or

name: Deploy to Dash Enterprise

on:
  push:
    branches:
      - main

jobs:
  deploy:
    name: 'Deploy to Dash Enterprise'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: plotly/de-deploy@add-adding-env-variables
        with:
           env_vars: FOO=BAR FOO_SECRET=${{ secrets.FOO_SECRET }}

Or

name: Deploy to Dash Enterprise

on:
  push:
    branches:
      - main

jobs:
  deploy:
    name: 'Deploy to Dash Enterprise'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: plotly/de-deploy@add-adding-env-variables
        with:
          env_vars: |
            FOO=BAR
            FOO_SECRET=${{ secrets.FOO_SECRET }}

(Note that | must be there)

What do you think?


### Preview deploy on pull request
This action will deploy branches using the `on: pull_request: types: ['opened', 'edited', 'synchronize', 'closed']` trigger as `https://${DE_HOST}/${APP_NAME}-${event_number}`, e.g. if you are deploying an app called `inventory-analytics` to `example.plotly.host` and your PR number is `15`, the deploy preview would be available at `https://example.plotly.host/inventory-analytics-15` and would be redeployed on every new commit to that PR.
Expand Down
12 changes: 11 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ inputs:
description: True to create a persistent filesystem for the app.
type: boolean
required: false

env_vars:
description: Environment variables to add. Separate multiple variables with a space.
required: false
type: string



runs:
Expand Down Expand Up @@ -138,6 +142,12 @@ runs:
shell: bash
if: github.event.action != 'closed'
run: |
# Split the environment variables by space and add them
IFS=' ' read -r -a env_vars_array <<< "${{ inputs.env_vars }}"
for env_var in "${env_vars_array[@]}"
do
de --no-keyfile apps update --name ${{ steps.app_name.outputs.app_name }} --add-environment-variable "$env_var"
done
de --no-keyfile deploy ${{ inputs.app_directory }} --name ${{ steps.app_name.outputs.app_name }} --message "Deployed commit: $GITHUB_SHA" -y
de --no-keyfile apps update --name ${{ steps.app_name.outputs.app_name }} --add-group-co-owner "${{ inputs.group_co_owners }}" --add-group-viewer "${{ inputs.group_viewers }}"
env:
Expand Down