deta-deploy-action icon indicating copy to clipboard operation
deta-deploy-action copied to clipboard

Suggestion: environment deploys would be cool!

Open PascaleBeier opened this issue 4 years ago • 2 comments

Hey,

thanks for that nice little action. Love it.

In my current workflow, I need to create a .env file and manually call ~/.deta/bin/deta update -e .env to propagate current environment variables to a deployed micro.

It's not that big of a deal, but maybe this action could ease that up.

Suggestion

Add a deta-update-env flag:

deta-update-env is a path to a .env file, that does nothing more than running deta update -e with the given parameter as argument. (See https://docs.deta.sh/docs/micros/env_vars/)

I would suggest that you'd have to explicitly enable it by passing a string.

name: Deploy to Deta
on: push

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: BogDAAAMN/[email protected]
        with:
          deta-update-env: '.env' # Optional: environment file to be deployed to Deta. Defaults to '', which disables this. See https://docs.deta.sh/docs/micros/env_vars/

If you like me to, I can figure out a PR as well.

PascaleBeier avatar Aug 15 '21 09:08 PascaleBeier

Helloo @PascaleBeier! Great suggestion, I have a few repos that would benefit of that as well.

I am just thinking is it a common use case to push .env files to GitHub so they can be pushed to Deta? I do use deta update -e, but all the .env files contain secret keys and tokens that I always store locally. What do you think?

bogdaaamn avatar Aug 17 '21 11:08 bogdaaamn

Hey @BogDAAAMN - sorry that I wasn't more clear, I'm really bad at describing things. You are correct, and this is my use case.

  • My applications use environment variables
  • My applications don't version control any .env files
  • My applications expect environment variables to present after deployment

So what I currently do to get my environment variables into the micro:


  - uses: BogDAAAMN/[email protected]
    name: Deploy to Deta
    with:
        deta-access-token: ${{ secrets.DETA_ACCESS_TOKEN }}
        deta-name: ${{ secrets.DETA_MICRO }}
    
  - name: Set environment variables
    run: # script to set environment variables ...

  - name: Create .env file
    run: # script to create .env file from above environment variables ...

  - name: Deploy environment variables
    run: |
      export DETA_ACCESS_TOKEN=${{ secrets.DETA_ACCESS_TOKEN }}
      ~/.deta/bin/deta update -e .env

So I would love for this action to provide a shortcut around that, given that the action user has some environment variables set he wants to propagate to the micro.

EDIT:

I put together a small Repository to illustrate. Environment Variables might be produced during build time, or might be preset in the build environment. it has the exact Github Workflow running on https://wymc9q.deta.dev/.

PascaleBeier avatar Aug 17 '21 14:08 PascaleBeier