Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running locally using act: ACTION_TOKEN variable not set #110

Open
LukeSavefrogs opened this issue Sep 29, 2023 · 6 comments
Open

Comments

@LukeSavefrogs
Copy link

LukeSavefrogs commented Sep 29, 2023

Running the following causes the workflow to fail with the error in the subject:

- name: Install composer dependencies
  uses: php-actions/composer@v6
  with:
    php_version: '8.2'
    args: --no-dev --no-interaction --prefer-dist --optimize-autoloader

I tried adding ACTION_TOKEN as an env variable but it still doesn't work:

- name: Install composer dependencies
  uses: php-actions/composer@v6
  with:
    php_version: '8.2'
    args: --no-dev --no-interaction --prefer-dist --optimize-autoloader
  env:
    ACTION_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The action does NOT work even removing all optional parameters:

- name: Install composer dependencies
  uses: php-actions/composer@v6
@g105b
Copy link
Member

g105b commented Sep 29, 2023

Are you running this on Github or a self-hosted runner?

@LukeSavefrogs
Copy link
Author

Are you running this on Github or a self-hosted runner?

I'm using act to test the action locally

@g105b
Copy link
Member

g105b commented Sep 30, 2023

Ok thank you. It would be super useful to use act, so I'll try and replicate and figure out a fix, but I've never had much luck with act - it "feels" like GitHub actions, but it isn't really running anything official and there are lots of gaps, in my experience.

@LukeSavefrogs
Copy link
Author

Ok thank you. It would be super useful to use act, so I'll try and replicate and figure out a fix, but I've never had much luck with act - it "feels" like GitHub actions, but it isn't really running anything official and there are lots of gaps, in my experience.

Thank you for your patience @g105b.

Until now I've found act very useful in most of the cases to test actions locally before deploying. Only times I couldn't use it is for Windows/macOs runners (which do not support natively and i didn't have the time to find how to configure properly) or very rarely with some actions (as in this case)

@g105b g105b changed the title Error: ACTION_TOKEN variable not set Error running using act: ACTION_TOKEN variable not set Oct 1, 2023
@g105b g105b changed the title Error running using act: ACTION_TOKEN variable not set Error running locally using act: ACTION_TOKEN variable not set Oct 1, 2023
@SierraKomodo
Copy link

After some digging and research on my end, I've found a solution - It's essentially an extra step needed in running act with this, or any other action that needs an ACTION_TOKEN.

Some relevant links:

I have act installed as a github cli extension, so the solution for me was to simply add -s GITHUB_TOKEN="$(gh auth token)" as an argument to my gh act call, and that resolved the ACTION_TOKEN error.

If you don't use it as a github cli extension, it looks like you can also resolve this by:

@g105b
Copy link
Member

g105b commented Oct 5, 2023

Thank you so much @SierraKomodo. I hadn't used ACT personally, so this will really help me get going, and once I've learnt how to use it I'll add some documentation to this repo for future ACT users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants