Act: Support dotenv

Created on 5 Mar 2020  ·  9Comments  ·  Source: nektos/act

I'm storing all my secrets passed to GitHub in a dotenv and it would be sooo helpful if I could do act -f .env pull_request.

All 9 comments

Closing to keep discussion going on #123

@muuvmuuv - can you review the suggestion there and see if that would help or if .env is the better way to go

implemented in #133

Oh, that was fast! Sorry for the delay and thank you! :)

Doesn't seem to work.

The .env.build is in the root.

❯ act -b -r -v --env-file .env.build fork
DEBU[0000] Loading environment from /Users/marvinheilemann/Development/Portfolio/.env.build
DEBU[0000] Loading workflows from '/Users/marvinheilemann/Development/Portfolio/.github/workflows'
DEBU[0000] Reading workflow '/Users/marvinheilemann/Development/Portfolio/.github/workflows/build.yml'
DEBU[0000] Reading workflow '/Users/marvinheilemann/Development/Portfolio/.github/workflows/fork.yml'
DEBU[0000] Reading workflow '/Users/marvinheilemann/Development/Portfolio/.github/workflows/lint.yml'
DEBU[0000] Reading workflow '/Users/marvinheilemann/Development/Portfolio/.github/workflows/notify.yml'
DEBU[0000] Reading workflow '/Users/marvinheilemann/Development/Portfolio/.github/workflows/stale.yml'
DEBU[0000] Planning event: fork
DEBU[0000] Loading slug from git directory '/Users/marvinheilemann/Development/Portfolio/.git'
DEBU[0000] Found revision: 078042c0e1c7955e49f19816f18a0a0c939bac50
DEBU[0000] Loading revision from git directory '/Users/marvinheilemann/Development/Portfolio/.git'
DEBU[0000] Found revision: 078042c0e1c7955e49f19816f18a0a0c939bac50
DEBU[0000] HEAD points to '078042c0e1c7955e49f19816f18a0a0c939bac50'
DEBU[0000] HEAD matches refs/heads/development
DEBU[0000] using github ref: refs/heads/development
[Fork created/Notify by email] 🚀  Start image=node:12.6-buster-slim
[Fork created/Notify by email]   🐳  docker pull node:12.6-buster-slim
DEBU[0000] Image exists? true
[Fork created/Notify by email]   🐳  docker create image=node:12.6-buster-slim entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Fork created/Notify by email]   🐳  docker run image=node:12.6-buster-slim entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Fork created/Notify by email] Starting container: ed74bfe31369405cd43a4ae9556f2d4bb89b46dae4fcb1e303091687208c53ea
[Fork created/Notify by email] Started container: ed74bfe31369405cd43a4ae9556f2d4bb89b46dae4fcb1e303091687208c53ea
DEBU[0000] Writing entry to tarball workflow/event.json len:2
DEBU[0000] Writing entry to tarball home/.act len:0
[Fork created/Notify by email] Extracting content to '/github/'
DEBU[0000] Loading slug from git directory '/Users/marvinheilemann/Development/Portfolio/.git'
DEBU[0000] Found revision: 078042c0e1c7955e49f19816f18a0a0c939bac50
DEBU[0000] Loading revision from git directory '/Users/marvinheilemann/Development/Portfolio/.git'
DEBU[0000] Found revision: 078042c0e1c7955e49f19816f18a0a0c939bac50
DEBU[0000] HEAD points to '078042c0e1c7955e49f19816f18a0a0c939bac50'
DEBU[0000] HEAD matches refs/heads/development
DEBU[0000] using github ref: refs/heads/development
[Fork created/Notify by email] ⭐  Run echo '${{secrets.MAIL_USERNAME}}'
DEBU[0000] Loading slug from git directory '/Users/marvinheilemann/Development/Portfolio/.git'
DEBU[0000] Found revision: 078042c0e1c7955e49f19816f18a0a0c939bac50
DEBU[0000] Loading revision from git directory '/Users/marvinheilemann/Development/Portfolio/.git'
DEBU[0000] Found revision: 078042c0e1c7955e49f19816f18a0a0c939bac50
DEBU[0000] HEAD points to '078042c0e1c7955e49f19816f18a0a0c939bac50'
DEBU[0000] HEAD matches refs/heads/development
DEBU[0000] using github ref: refs/heads/development
DEBU[0000] Wrote command 'echo 'undefined'' to 'workflow/0'
DEBU[0000] Writing entry to tarball workflow/0 len:32
[Fork created/Notify by email] Extracting content to '/github/'
[Fork created/Notify by email] Exec command '[bash --noprofile --norc -eo pipefail /github/workflow/0]'
| undefined
[Fork created/Notify by email]   ✅  Success - echo '${{secrets.MAIL_USERNAME}}'
name: Fork created

on:
  fork:

jobs:
  notify_email:
    name: Notify by email
    runs-on: ubuntu-latest

    steps:
      - run: echo '${{secrets.MAIL_USERNAME}}'

You still need to define secrets via act -s MAIL_USERNAME

If you omit the value then act will look for an env variable that can be provided in the .env file

Ah, you should note that in the README, but why is that needed? Wouldn't it be cleaner if all the stuff from the dotenv is loaded as a secret?

Good point @muuvmuuv - so in that case, would you like _all_ environment variables to become available as secrets?

Yes, for me the GitHub secrets page is nothing else than a local .env.

You still need to define secrets via act -s MAIL_USERNAME

If you omit the value then act will look for an env variable that can be provided in the .env file

This is better documented; it took me quite a while to figure out this env file could work! 😅

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kochetkovIT picture kochetkovIT  ·  4Comments

mheap picture mheap  ·  5Comments

helaili picture helaili  ·  3Comments

magiskboy picture magiskboy  ·  3Comments

justincy picture justincy  ·  3Comments