[GH-ISSUE #1131] Secrets passed per env file can not be made available in SSH action #638

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

Originally created by @dschuessler on GitHub (Apr 18, 2022).
Original GitHub issue: https://github.com/nektos/act/issues/1131

I am not sure whether to post it here or over at https://github.com/appleboy/ssh-action/issues because I don't know on which side the issue lies.

System information

  • Operating System: macOS 12.3.1
  • Architecture: x64
  • Apple M1: no
  • Docker version: 20.10.13
  • Docker image used in act: ubuntu:full-20.04
  • act version: act version 0.2.26

Steps to reproduce

  1. Create the following file at .github/workflows/test.yml:
on:
  push:
    branches: [main]

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - name: executing remote ssh commands using ssh key
        uses: appleboy/ssh-action@master
        env:
          GH_USER: ${{ secrets.GH_USER }}
          GH_PASSWORD: ${{ secrets.GH_PASSWORD }}
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.SSH_USERNAME }}
          key: ${{ secrets.SSH_PRIVATE_KEY_PROD }}
          port: ${{ secrets.SSH_PORT }}
          envs: GH_USER,GH_PASSWORD
          script: |
            echo "$GH_USER:$GH_PASSWORD"
  1. Create test.env file in the project directory with the following content. Replace the HOST and SSH_USERNAME variable with the credentials of a server you have access to.
HOST=yourhost
SSH_USERNAME=yourusername
SSH_PORT=22
GH_USER=foo
GH_PASSWORD=bar
  1. Run with the following command (Replace ~/.ssh/id_rsa with the correct path to your SSH key for your server.):
act -s SSH_PRIVATE_KEY_PROD="$(< ~/.ssh/id_rsa)" --env-file test.env

Expected behaviour

The secrets GH_USER and GH_PASSWORD are available in the script passed to ssh-action.

| ======CMD======
| echo "$GH_USER:$GH_PASSWORD"
| 
| ======END======
| out: ***:***
| ==============================================
| ✅ Successfully executed commands to all host.
| ==============================================

Actual behaviour

The secrets GH_USER and GH_PASSWORD are not available in the script.

| ======CMD======
| echo "$GH_USER:$GH_PASSWORD"
| 
| ======END======
| out: :
| ==============================================
| ✅ Successfully executed commands to all host.
| ==============================================

act shows the expected behavior though when passing the missing secrets via command line flags:

act -s SSH_PRIVATE_KEY_PROD="$(< ~/.ssh/id_rsa)" -s GH_USER=foo -s GH_PASSWORD=bar --env-file prod.env
Originally created by @dschuessler on GitHub (Apr 18, 2022). Original GitHub issue: https://github.com/nektos/act/issues/1131 I am not sure whether to post it here or over at https://github.com/appleboy/ssh-action/issues because I don't know on which side the issue lies. ## System information - Operating System: macOS 12.3.1 - Architecture: x64 - Apple M1: no - Docker version: 20.10.13 - Docker image used in `act`: ubuntu:full-20.04 - `act` version: act version 0.2.26 ## Steps to reproduce 1. Create the following file at `.github/workflows/test.yml`: ``` on: push: branches: [main] jobs: build: name: Build runs-on: ubuntu-latest steps: - name: executing remote ssh commands using ssh key uses: appleboy/ssh-action@master env: GH_USER: ${{ secrets.GH_USER }} GH_PASSWORD: ${{ secrets.GH_PASSWORD }} with: host: ${{ secrets.HOST }} username: ${{ secrets.SSH_USERNAME }} key: ${{ secrets.SSH_PRIVATE_KEY_PROD }} port: ${{ secrets.SSH_PORT }} envs: GH_USER,GH_PASSWORD script: | echo "$GH_USER:$GH_PASSWORD" ``` 2. Create `test.env` file in the project directory with the following content. Replace the `HOST` and `SSH_USERNAME` variable with the credentials of a server you have access to. ``` HOST=yourhost SSH_USERNAME=yourusername SSH_PORT=22 GH_USER=foo GH_PASSWORD=bar ``` 3. Run with the following command (Replace `~/.ssh/id_rsa` with the correct path to your SSH key for your server.): ``` act -s SSH_PRIVATE_KEY_PROD="$(< ~/.ssh/id_rsa)" --env-file test.env ``` ## Expected behaviour The secrets `GH_USER` and `GH_PASSWORD` are available in the script passed to `ssh-action`. ``` | ======CMD====== | echo "$GH_USER:$GH_PASSWORD" | | ======END====== | out: ***:*** | ============================================== | ✅ Successfully executed commands to all host. | ============================================== ``` ## Actual behaviour The secrets `GH_USER` and `GH_PASSWORD` are not available in the script. ``` | ======CMD====== | echo "$GH_USER:$GH_PASSWORD" | | ======END====== | out: : | ============================================== | ✅ Successfully executed commands to all host. | ============================================== ``` `act` shows the expected behavior though when passing the missing secrets via command line flags: ``` act -s SSH_PRIVATE_KEY_PROD="$(< ~/.ssh/id_rsa)" -s GH_USER=foo -s GH_PASSWORD=bar --env-file prod.env ```
kerem 2026-03-01 21:45:08 +03:00
Author
Owner

@github-actions[bot] commented on GitHub (May 19, 2022):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:1130795203 --> @github-actions[bot] commented on GitHub (May 19, 2022): Issue is stale and will be closed in 14 days unless there is new activity
Author
Owner

@kmai commented on GitHub (May 19, 2022):

just a thought: you're using --env-file even though you refer to them as secrets in the workflow

<!-- gh-comment-id:1132180784 --> @kmai commented on GitHub (May 19, 2022): just a thought: you're using `--env-file` even though you refer to them as secrets in the workflow
Author
Owner

@github-actions[bot] commented on GitHub (Jun 19, 2022):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:1159586411 --> @github-actions[bot] commented on GitHub (Jun 19, 2022): Issue is stale and will be closed in 14 days unless there is new activity
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#638
No description provided.