[GH-ISSUE #1558] Add support for Github Actions Variables #784

Closed
opened 2026-03-01 21:46:20 +03:00 by kerem · 25 comments
Owner

Originally created by @lktslionel on GitHub (Jan 13, 2023).
Original GitHub issue: https://github.com/nektos/act/issues/1558

Hello,

GitHub releases GitHub Actions Variables. It will be great to be able the use vars.VAR_NAME with our workflow document.

See: https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28

Thanks
Regards

Originally created by @lktslionel on GitHub (Jan 13, 2023). Original GitHub issue: https://github.com/nektos/act/issues/1558 Hello, GitHub releases GitHub Actions Variables. It will be great to be able the use `vars.VAR_NAME` with our workflow document. See: https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28 Thanks Regards
kerem 2026-03-01 21:46:20 +03:00
Author
Owner

@lktslionel commented on GitHub (Jan 13, 2023):

I'm open to contributing but I need guidance on how to get started and which part of the code is handling that part.
I think it will be similar to how env.EEEE and secrets.XXX are being handled but apart from that, I am completely blind 😄 .

<!-- gh-comment-id:1381932457 --> @lktslionel commented on GitHub (Jan 13, 2023): I'm open to contributing but I need guidance on how to get started and which part of the code is handling that part. I think it will be similar to how `env.EEEE` and `secrets.XXX` are being handled but apart from that, I am completely blind 😄 .
Author
Owner

@KnisterPeter commented on GitHub (Jan 13, 2023):

Hi @lktslionel,
first of all I think there need to be an idea how to add this to act. Currently there is no access to GitHub APIs and I do think it shouldn't be there. Secrets and Env-Vars are set via the command line and I could think of that for vars as well.

A starting point would be to add them to the expression parser (stating here: https://github.com/nektos/act/blob/master/pkg/exprparser/interpreter.go#L150)
And then work up all the way to the command line arguments.

<!-- gh-comment-id:1381936502 --> @KnisterPeter commented on GitHub (Jan 13, 2023): Hi @lktslionel, first of all I think there need to be an idea how to add this to act. Currently there is no access to GitHub APIs and I do think it shouldn't be there. Secrets and Env-Vars are set via the command line and I could think of that for vars as well. A starting point would be to add them to the expression parser (stating here: https://github.com/nektos/act/blob/master/pkg/exprparser/interpreter.go#L150) And then work up all the way to the command line arguments.
Author
Owner

@grantcarthew commented on GitHub (Apr 26, 2023):

I tried to pass "vars" in the environment variable command line option:

act --env 'vars.FOO=BAR'

This didn't work.
This is a show-stopper for me. Well, I can't have an action that works with GitHub and act.

Sorry, I'm not a Go dev yet and am time-limited (aren't we all?).

<!-- gh-comment-id:1522670085 --> @grantcarthew commented on GitHub (Apr 26, 2023): I tried to pass "vars" in the environment variable command line option: ```bash act --env 'vars.FOO=BAR' ``` This didn't work. This is a show-stopper for me. Well, I can't have an action that works with GitHub and `act`. Sorry, I'm not a Go dev yet and am time-limited (aren't we all?).
Author
Owner

@mcascone commented on GitHub (Apr 28, 2023):

+1 agree, not supporting variables - as opposed to environment variables - is a big miss. I don't even have environment variables in my personal repo. 💯 agree with following the same patters as .env and .secrets: support .vars with the same mechanisms: default to .vars, override with --vars-file.

Thanks! :)

<!-- gh-comment-id:1527679799 --> @mcascone commented on GitHub (Apr 28, 2023): +1 agree, not supporting variables - as opposed to _environment_ variables - is a big miss. I don't even have environment variables in my personal repo. 💯 agree with following the same patters as `.env` and `.secrets`: support `.vars` with the same mechanisms: default to `.vars`, override with `--vars-file`. Thanks! :)
Author
Owner

@haktan-suren commented on GitHub (May 6, 2023):

+1

<!-- gh-comment-id:1536972581 --> @haktan-suren commented on GitHub (May 6, 2023): +1
Author
Owner

@mwierzchowski commented on GitHub (May 6, 2023):

IMHO, all the contexts (like env, vars, secrets) should be handled the same way by act. No need for integration with the GitHub API - probably that would be completely undesired since may lead to unexpected sideeffects. As additional thing to consider, all types contexts could be defined in one file (with separate sections). This could simplify managing all the values at once and simplify setup (e.g. 1 entry in the .gitignore). In the scenario where all the contexts are defined in one file, we could consider format a little more human readable. YAML or TOML maybe?

<!-- gh-comment-id:1537131205 --> @mwierzchowski commented on GitHub (May 6, 2023): IMHO, all the contexts (like env, vars, secrets) should be handled the same way by act. No need for integration with the GitHub API - probably that would be completely undesired since may lead to unexpected sideeffects. As additional thing to consider, all types contexts could be defined in one file (with separate sections). This could simplify managing all the values at once and simplify setup (e.g. 1 entry in the .gitignore). In the scenario where all the contexts are defined in one file, we could consider format a little more human readable. YAML or TOML maybe?
Author
Owner

@kferrone commented on GitHub (May 11, 2023):

This needs to be very high priority. This is not ready for use without it.

<!-- gh-comment-id:1544779007 --> @kferrone commented on GitHub (May 11, 2023): This needs to be very high priority. This is not ready for use without it.
Author
Owner

@adamhalesworth commented on GitHub (May 12, 2023):

It would be great to be able to supply vars to act, e.g. to provide a RUN_OFFSET to maintain build continuity (which is my use case). Using secrets is workable, but it makes the process cumbersome since the value is hidden in the UI.

As @mwierzchowski suggested, YAML or TOML is very readable and could simplify context configuration, but even having this implemented in the same format as .env would be fantastic.

<!-- gh-comment-id:1545603510 --> @adamhalesworth commented on GitHub (May 12, 2023): It would be great to be able to supply `vars` to `act`, e.g. to provide a `RUN_OFFSET` to maintain build continuity (which is my use case). Using `secrets` is workable, but it makes the process cumbersome since the value is hidden in the UI. As @mwierzchowski suggested, YAML or TOML is very readable and could simplify context configuration, but even having this implemented in the same format as `.env` would be fantastic.
Author
Owner

@basos9 commented on GitHub (May 12, 2023):

This is needed for sure

<!-- gh-comment-id:1545700014 --> @basos9 commented on GitHub (May 12, 2023): This is needed for sure
Author
Owner

@mcascone commented on GitHub (May 12, 2023):

@KnisterPeter, I opened https://github.com/nektos/act/pull/1802 to implement this, but i'm really working blind here. I just copied the pattern used for the Env var, and created a Vars flow. I'm happy to follow this through but i'll need to some guidance on where to go next.

<!-- gh-comment-id:1545885691 --> @mcascone commented on GitHub (May 12, 2023): @KnisterPeter, I opened https://github.com/nektos/act/pull/1802 to implement this, but i'm really working blind here. I just copied the pattern used for the Env var, and created a Vars flow. I'm happy to follow this through but i'll need to some guidance on where to go next.
Author
Owner

@KnisterPeter commented on GitHub (May 24, 2023):

@mcascone You probably need to go through all act code here from the cli options parsing to all call sides of the expression parser. This is not the smallest change and up to now you only touched the surface (the parser). I would suggest to make yourself familiar with the whole codebase.

<!-- gh-comment-id:1560589387 --> @KnisterPeter commented on GitHub (May 24, 2023): @mcascone You probably need to go through all act code here from the cli options parsing to all call sides of the expression parser. This is not the smallest change and up to now you only touched the surface (the parser). I would suggest to make yourself familiar with the whole codebase.
Author
Owner

@wildsheepz commented on GitHub (May 31, 2023):

@KnisterPeter, I made the changes needed to add a --var-file, tested using a workflow to verify that secrets is still masked and ${{ vars.Example }} is working.

<!-- gh-comment-id:1569463176 --> @wildsheepz commented on GitHub (May 31, 2023): @KnisterPeter, I made the changes needed to add a `--var-file`, tested using a workflow to verify that secrets is still masked and `${{ vars.Example }}` is working.
Author
Owner

@askb commented on GitHub (May 31, 2023):

When is this fix going to be out! Having the same issue with out tests and workflow. It's going to be a pain to rewrite all the workflows to change the all the var to env.

[Gerrit Verify/prepare] Unable to interpolate expression 'format('{0}', vars.GERRIT_SSH_USER)': Unavailable context: vars
[Gerrit Verify/prepare] Unable to interpolate expression 'format('{0}', vars.GERRIT_KNOWN_HOSTS)': Unavailable context: vars
[Gerrit Verify/prepare] Unable to interpolate expression 'format('{0}', vars.GERRIT_SERVER)': Unavailable context: vars
<!-- gh-comment-id:1570281319 --> @askb commented on GitHub (May 31, 2023): When is this fix going to be out! Having the same issue with out tests and workflow. It's going to be a pain to rewrite all the workflows to change the all the var to env. ``` [Gerrit Verify/prepare] Unable to interpolate expression 'format('{0}', vars.GERRIT_SSH_USER)': Unavailable context: vars [Gerrit Verify/prepare] Unable to interpolate expression 'format('{0}', vars.GERRIT_KNOWN_HOSTS)': Unavailable context: vars [Gerrit Verify/prepare] Unable to interpolate expression 'format('{0}', vars.GERRIT_SERVER)': Unavailable context: vars ```
Author
Owner

@wildsheepz commented on GitHub (May 31, 2023):

Well, I have a full time job and writing the unit tests to satisfy the coverage requirements is going to take time. You could just compile it from my fork and use that if you need it urgently.

<!-- gh-comment-id:1570423770 --> @wildsheepz commented on GitHub (May 31, 2023): Well, I have a full time job and writing the unit tests to satisfy the coverage requirements is going to take time. You could just compile it from my fork and use that if you need it urgently.
Author
Owner

@grantcarthew commented on GitHub (Jun 1, 2023):

Hi Kuan @wildsheepz,
Just wanted to say thanks mate. It looks like you're the only one stepping up for this and there will be many people interested. Your work is appreciated.

<!-- gh-comment-id:1571284593 --> @grantcarthew commented on GitHub (Jun 1, 2023): Hi Kuan @wildsheepz, Just wanted to say thanks mate. It looks like you're the only one stepping up for this and there will be many people interested. Your work is appreciated.
Author
Owner

@wildsheepz commented on GitHub (Jun 10, 2023):

#1833 has been merged into master.

<!-- gh-comment-id:1585863734 --> @wildsheepz commented on GitHub (Jun 10, 2023): #1833 has been merged into master.
Author
Owner

@askb commented on GitHub (Jun 12, 2023):

Thanks for fixing this Kuan @wildsheepz

<!-- gh-comment-id:1586471594 --> @askb commented on GitHub (Jun 12, 2023): Thanks for fixing this Kuan @wildsheepz
Author
Owner

@duzenko commented on GitHub (Jun 20, 2023):

a@a-virtual-machine:/mnt/hgfs/Remote/cashare-react-ui$ ./bin/act --var FTP_DIR_STAGING=qwe
Error: unknown flag: --var
<!-- gh-comment-id:1598669769 --> @duzenko commented on GitHub (Jun 20, 2023): ``` a@a-virtual-machine:/mnt/hgfs/Remote/cashare-react-ui$ ./bin/act --var FTP_DIR_STAGING=qwe Error: unknown flag: --var ```
Author
Owner

@wildsheepz commented on GitHub (Jun 20, 2023):

a@a-virtual-machine:/mnt/hgfs/Remote/cashare-react-ui$ ./bin/act --var FTP_DIR_STAGING=qwe
Error: unknown flag: --var

It's merged into main, but the version has not bumped yet. If you need it now, you will need to compile master on your own.

<!-- gh-comment-id:1598811797 --> @wildsheepz commented on GitHub (Jun 20, 2023): > ``` > a@a-virtual-machine:/mnt/hgfs/Remote/cashare-react-ui$ ./bin/act --var FTP_DIR_STAGING=qwe > Error: unknown flag: --var > ``` It's merged into main, but the version has not bumped yet. If you need it now, you will need to compile master on your own.
Author
Owner

@duzenko commented on GitHub (Jun 20, 2023):

Sorry, whose job is it to "bump the version"?

<!-- gh-comment-id:1598819757 --> @duzenko commented on GitHub (Jun 20, 2023): Sorry, whose job is it to "bump the version"?
Author
Owner

@haktan-suren commented on GitHub (Jun 25, 2023):

For those who don't know how to build from master

brew unlink act  
brew install act --HEAD
<!-- gh-comment-id:1605785857 --> @haktan-suren commented on GitHub (Jun 25, 2023): For those who don't know how to build from master ``` brew unlink act brew install act --HEAD ```
Author
Owner

@askb commented on GitHub (Jul 4, 2023):

For those who don't know how to build from master

brew unlink act  
brew install act --HEAD

Is there an equivalent to build / install the binary using the HEAD on other platforms?
ex on linux we use curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | bash

<!-- gh-comment-id:1619347578 --> @askb commented on GitHub (Jul 4, 2023): > For those who don't know how to build from master > > ``` > brew unlink act > brew install act --HEAD > ``` Is there an equivalent to build / install the binary using the HEAD on other platforms? ex on linux we use `curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | bash`
Author
Owner

@dragonprevost commented on GitHub (Aug 10, 2023):

Thank you @wildsheepz 🙏

<!-- gh-comment-id:1673945988 --> @dragonprevost commented on GitHub (Aug 10, 2023): Thank you @wildsheepz 🙏
Author
Owner

@L-Sypniewski commented on GitHub (Aug 17, 2024):

I don't want to open an issue since I'm not sure if the problem is on my side, but the variables don't work for me (secrets are correctly substituted). I've tried both with .env file and passing a value as a commandline parameter:

act -j  deploy-chagnes-to-dev-db --secret-file ./.act/.secrets -var SUPABASE_DEV_PROJECT_ID=<ID_VALUE> 

Replacing ${{ vars.SUPABASE_DEV_PROJECT_ID }} with the actual value fixes the problem.

According to the docs from a linked PR it should work: To run act with repository variables that are acessible inside the workflow via ${{ vars.VARIABLE }},

A piece of code from my Github actions:

  deploy-chagnes-to-dev-db:
    defaults:
      run:
        working-directory: ./Frontend/
    name: Lint Supabase and apply migrations to dev instance
    runs-on: ubuntu-24.04
    env:
      SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_DEV_ACCESS_TOKEN }}
      SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DEV_DB_PASSWORD }}
      SUPABASE_PROJECT_ID: ${{ vars.SUPABASE_DEV_PROJECT_ID }}
    timeout-minutes: 10
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Install Supabase CLI
        uses: supabase/setup-cli@v1
      - name: Create fake .env file for Supabase CLI
        run: |
          echo 'GITHUB_CLIENT_ID="SOMEID"' > .env
          echo 'GITHUB_SECRET="SOMESECRET"' >> .env
          echo 'SENDGRID_API_KEY="SOMEKEY"' >> .env
          echo 'OPENAI_API_KEY="SOMEKEY"' >> .env
      # - name: Start supabase DB
        # run: supabase db start
      # - name: Lint Supabase
        # run: supabase db lint
      - name: Apply migrations to dev instance
        run: |
            supabase link --project-ref "$SUPABASE_PROJECT_ID"
            supabase db reset --linked
<!-- gh-comment-id:2294933563 --> @L-Sypniewski commented on GitHub (Aug 17, 2024): I don't want to open an issue since I'm not sure if the problem is on my side, but the variables don't work for me (secrets are correctly substituted). I've tried both with .env file and passing a value as a commandline parameter: ```sh act -j deploy-chagnes-to-dev-db --secret-file ./.act/.secrets -var SUPABASE_DEV_PROJECT_ID=<ID_VALUE> ``` Replacing `${{ vars.SUPABASE_DEV_PROJECT_ID }}` with the actual value fixes the problem. According to the docs from a linked PR it should work: `To run act with repository variables that are acessible inside the workflow via ${{ vars.VARIABLE }},` A piece of code from my Github actions: ```yml deploy-chagnes-to-dev-db: defaults: run: working-directory: ./Frontend/ name: Lint Supabase and apply migrations to dev instance runs-on: ubuntu-24.04 env: SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_DEV_ACCESS_TOKEN }} SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DEV_DB_PASSWORD }} SUPABASE_PROJECT_ID: ${{ vars.SUPABASE_DEV_PROJECT_ID }} timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v4 - name: Install Supabase CLI uses: supabase/setup-cli@v1 - name: Create fake .env file for Supabase CLI run: | echo 'GITHUB_CLIENT_ID="SOMEID"' > .env echo 'GITHUB_SECRET="SOMESECRET"' >> .env echo 'SENDGRID_API_KEY="SOMEKEY"' >> .env echo 'OPENAI_API_KEY="SOMEKEY"' >> .env # - name: Start supabase DB # run: supabase db start # - name: Lint Supabase # run: supabase db lint - name: Apply migrations to dev instance run: | supabase link --project-ref "$SUPABASE_PROJECT_ID" supabase db reset --linked ```
Author
Owner

@y-takebe commented on GitHub (Jan 11, 2025):

@L-Sypniewski

I suggest changing -var to --var. It works in my local environment.

https://nektosact.com/usage/index.html?highlight=var#vars

<!-- gh-comment-id:2585014207 --> @y-takebe commented on GitHub (Jan 11, 2025): @L-Sypniewski I suggest changing `-var` to `--var`. It works in my local environment. https://nektosact.com/usage/index.html?highlight=var#vars
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#784
No description provided.