[GH-ISSUE #1972] Multiple line variable in .env file #944

Closed
opened 2026-03-01 21:47:37 +03:00 by kerem · 3 comments
Owner

Originally created by @chrowe on GitHub (Aug 16, 2023).
Original GitHub issue: https://github.com/nektos/act/issues/1972

Bug report info

act version:            0.2.49
GOOS:                   darwin
GOARCH:                 arm64
NumCPU:                 8
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
        /var/run/docker.sock
        $HOME/.docker/run/docker.sock
Config files:           
        /Users/[username]/.actrc:
                -P ubuntu-latest=catthehacker/ubuntu:act-latest
                -P ubuntu-22.04=catthehacker/ubuntu:act-22.04
                -P ubuntu-20.04=catthehacker/ubuntu:act-20.04
                -P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
        Go version:            go1.20.6
        Module path:           command-line-arguments
        Main version:          
        Main path:             
        Main checksum:         
        Build settings:
                -buildmode:           exe
                -compiler:            gc
                -ldflags:             -X main.version=0.2.49
                CGO_ENABLED:          1
                CGO_CFLAGS:           
                CGO_CPPFLAGS:         
                CGO_CXXFLAGS:         
                CGO_LDFLAGS:          
                GOARCH:               arm64
                GOOS:                 darwin
Docker Engine:
        Engine version:        24.0.2
        Engine runtime:        runc
        Cgroup version:        2
        Cgroup driver:         cgroupfs
        Storage driver:        overlay2
        Registry URI:          https://index.docker.io/v1/
        OS:                    Docker Desktop
        OS type:               linux
        OS version:            
        OS arch:               aarch64
        OS kernel:             5.15.49-linuxkit-pr
        OS CPU:                6
        OS memory:             11963 MB
        Security options:
                name=seccomp,profile=builtin
                name=cgroupns

Command used with act

act --container-architecture linux/amd64 --secret-file ../act.secrets workflow_dispatch

Describe issue

The readme says that the --secret-file "file format is the same as .env format"
Looking at https://hexdocs.pm/dotenvy/dotenv-file-format.html the way to handle multi line values is

MULTILINE = """
long text here,
e.g. a private SSH key
"""

But when I try that throws an error

No response

Workflow content

name: Deploy to AWS
on:
  on:
  push:
    branches:
      - main
  workflow_dispatch:
jobs:
  ssh-deploy:
    name: ssh-deploy
    runs-on: ubuntu-20.04
    steps:
    - name: cd in repo dir
      uses: appleboy/ssh-action@v1.0.0
      with:
        host: ${{ secrets.AWS_IP }}
        username: ${{ secrets.AWS_USERNAME }}
        key: ${{ secrets.SSH_KEY }}
        port: ${{ secrets.SSH_PORT }}
        script: whoami

Relevant log output

DEBU[0000] Loading environment from /Users/[username]/Github/act.secrets
FATA[0000] Error loading from /Users/Chris.Rowe/Github/act.secrets: unexpected character "\"" in variable name near "\"\n[VALUE_FROM_FILE]\n\"\"\""

Additional information

Looks like someone else was having a similar issue in https://github.com/nektos/act/issues/123#issuecomment-670055823

Originally created by @chrowe on GitHub (Aug 16, 2023). Original GitHub issue: https://github.com/nektos/act/issues/1972 ### Bug report info ```plain text act version: 0.2.49 GOOS: darwin GOARCH: arm64 NumCPU: 8 Docker host: DOCKER_HOST environment variable is not set Sockets found: /var/run/docker.sock $HOME/.docker/run/docker.sock Config files: /Users/[username]/.actrc: -P ubuntu-latest=catthehacker/ubuntu:act-latest -P ubuntu-22.04=catthehacker/ubuntu:act-22.04 -P ubuntu-20.04=catthehacker/ubuntu:act-20.04 -P ubuntu-18.04=catthehacker/ubuntu:act-18.04 Build info: Go version: go1.20.6 Module path: command-line-arguments Main version: Main path: Main checksum: Build settings: -buildmode: exe -compiler: gc -ldflags: -X main.version=0.2.49 CGO_ENABLED: 1 CGO_CFLAGS: CGO_CPPFLAGS: CGO_CXXFLAGS: CGO_LDFLAGS: GOARCH: arm64 GOOS: darwin Docker Engine: Engine version: 24.0.2 Engine runtime: runc Cgroup version: 2 Cgroup driver: cgroupfs Storage driver: overlay2 Registry URI: https://index.docker.io/v1/ OS: Docker Desktop OS type: linux OS version: OS arch: aarch64 OS kernel: 5.15.49-linuxkit-pr OS CPU: 6 OS memory: 11963 MB Security options: name=seccomp,profile=builtin name=cgroupns ``` ### Command used with act ```sh act --container-architecture linux/amd64 --secret-file ../act.secrets workflow_dispatch ``` ### Describe issue The readme says that the `--secret-file` "file format is the same as .env format" Looking at https://hexdocs.pm/dotenvy/dotenv-file-format.html the way to handle multi line values is ``` MULTILINE = """ long text here, e.g. a private SSH key """ ``` But when I try that throws an error ### Link to GitHub repository _No response_ ### Workflow content ```yml name: Deploy to AWS on: on: push: branches: - main workflow_dispatch: jobs: ssh-deploy: name: ssh-deploy runs-on: ubuntu-20.04 steps: - name: cd in repo dir uses: appleboy/ssh-action@v1.0.0 with: host: ${{ secrets.AWS_IP }} username: ${{ secrets.AWS_USERNAME }} key: ${{ secrets.SSH_KEY }} port: ${{ secrets.SSH_PORT }} script: whoami ``` ### Relevant log output ```sh DEBU[0000] Loading environment from /Users/[username]/Github/act.secrets FATA[0000] Error loading from /Users/Chris.Rowe/Github/act.secrets: unexpected character "\"" in variable name near "\"\n[VALUE_FROM_FILE]\n\"\"\"" ``` ### Additional information Looks like someone else was having a similar issue in https://github.com/nektos/act/issues/123#issuecomment-670055823
kerem 2026-03-01 21:47:37 +03:00
  • closed this issue
  • added the
    kind/bug
    label
Author
Owner

@ChristopherHX commented on GitHub (Aug 16, 2023):

Looks like your document is not for godotenv, but for another dotenv implementation. I don't even understand what spec it follows, it reads like a mix of bash, yaml, /etc/environment and others.

See https://nektosact.com/beginner/index.html#envsecrets-files-structure for an multiline example that works with it

This reminds me we should add a link to nektosact.com.

I strongly recommend yaml

  • well known multiline syntax
  • used for workflow files

just use the .yml or .yaml extension to use that format (--*-file options)

This reminds me I never documented yaml support of act.

<!-- gh-comment-id:1681190176 --> @ChristopherHX commented on GitHub (Aug 16, 2023): Looks like your document is not for [godotenv](https://github.com/joho/godotenv), but for another dotenv implementation. I don't even understand what spec it follows, it reads like a mix of bash, yaml, /etc/environment and others. See https://nektosact.com/beginner/index.html#envsecrets-files-structure for an multiline example that works with it This reminds me we should add a link to nektosact.com. I strongly recommend yaml - well known multiline syntax - used for workflow files just use the `.yml` or `.yaml` extension to use that format (`--*-file` options) This reminds me I never documented yaml support of act.
Author
Owner

@chrowe commented on GitHub (Aug 17, 2023):

Thanks, that worked.

Was also able to make it work with multi-line values with line breaks. https://github.com/bkeepers/dotenv#multi-line-values

Thanks for the link to the User Guide, I didn't see a link to that on the repo page.

<!-- gh-comment-id:1681432828 --> @chrowe commented on GitHub (Aug 17, 2023): Thanks, that worked. Was also able to make it work with multi-line values with line breaks. https://github.com/bkeepers/dotenv#multi-line-values Thanks for the link to the User Guide, I didn't see a link to that on the repo page.
Author
Owner

@ChristopherHX commented on GitHub (Aug 17, 2023):

I didn't see a link to that on the repo page

This is my PR to actually link the user guide in the readme https://github.com/nektos/act/pull/1973.

<!-- gh-comment-id:1681836473 --> @ChristopherHX commented on GitHub (Aug 17, 2023): > I didn't see a link to that on the repo page This is my PR to actually link the user guide in the readme https://github.com/nektos/act/pull/1973.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#944
No description provided.