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

[BUG] Git fails to authenticate when running locally with nektos/act #849

Closed
3 tasks done
CHarnel opened this issue Dec 12, 2022 · 5 comments
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@CHarnel
Copy link

CHarnel commented Dec 12, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

Hi, the action fails with message Failure - Main # "Calculating the previous and current SHA..." when running locally with nektos/act. It works as expected on GitHub actions.
I wrote on a seemingly related issue in nektos/act here.
The only reason I'm opening an issue here, is because another git-related action (this) runs in the same repo with the same setup.
I have a .secrets file with a PAT in GITHUB_TOKEN key.

To Reproduce

  1. In a local environment, having docker and act installed
  2. Create a repo with a sample workflow, having .secrets file with GITHUB_TOKEN key and your PAT as a value
  3. Run this: act workflow_dispatch --rm -W ./.github/workflows/your-workflow.yml --secret-file .secrets
  4. Of course change the name to the actual workflow name
  5. See aforementioned error

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

Run like on GitHub actions

Relevant log output

[rollout-prod/rollout] ⭐ Run Main # "Calculating the previous and current SHA..."
bash $GITHUB_ACTION_PATH/diff-sha.sh
[rollout-prod/rollout]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/changes-composite-changed-files-diff-sha.sh] user= workdir=
[rollout-prod/rollout]   ❓  ::group::changed-files-diff-sha
[rollout-prod/rollout]   💬  ::debug::Resolving repository path: /Users/.../projects/.../.
| Verifying git version...
| Valid git version found: (2.38.0)
| Running on a push event...
[rollout-prod/rollout]   💬  ::debug::Getting HEAD SHA...
| Warning: Permanently added the RSA host key for IP address '...' to the list of known hosts.
| git@github.com: Permission denied (publickey).
| fatal: Could not read from remote repository.
| 
| Please make sure you have the correct access rights
| and the repository exists.
[rollout-prod/rollout]   ❌  Failure - Main # "Calculating the previous and current SHA..."
bash $GITHUB_ACTION_PATH/diff-sha.sh
[rollout-prod/rollout] exitcode '128': failure
[rollout-prod/rollout]   ⚙  ::set-output:: unknown_files=
[rollout-prod/rollout]   ⚙  ::set-output:: all_modified_files=
[rollout-prod/rollout]   ⚙  ::set-output:: any_modified=
[rollout-prod/rollout]   ⚙  ::set-output:: only_modified=
[rollout-prod/rollout]   ⚙  ::set-output:: only_deleted=
[rollout-prod/rollout]   ⚙  ::set-output:: deleted_files=
[rollout-prod/rollout]   ⚙  ::set-output:: all_old_new_renamed_files=
[rollout-prod/rollout]   ⚙  ::set-output:: any_changed=
[rollout-prod/rollout]   ⚙  ::set-output:: other_deleted_files=
[rollout-prod/rollout]   ⚙  ::set-output:: added_files=
[rollout-prod/rollout]   ⚙  ::set-output:: renamed_files=
[rollout-prod/rollout]   ⚙  ::set-output:: all_changed_files=
[rollout-prod/rollout]   ⚙  ::set-output:: only_changed=
[rollout-prod/rollout]   ⚙  ::set-output:: any_deleted=
[rollout-prod/rollout]   ⚙  ::set-output:: other_changed_files=
[rollout-prod/rollout]   ⚙  ::set-output:: other_modified_files=
[rollout-prod/rollout]   ⚙  ::set-output:: copied_files=
[rollout-prod/rollout]   ⚙  ::set-output:: modified_files=
[rollout-prod/rollout]   ⚙  ::set-output:: type_changed_files=
[rollout-prod/rollout]   ⚙  ::set-output:: unmerged_files=
[rollout-prod/rollout]   ⚙  ::set-output:: all_changed_and_modified_files=
[rollout-prod/rollout]   ❌  Failure - Main Check for changes
[rollout-prod/rollout] exitcode '128': failure

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@CHarnel CHarnel added the bug Something isn't working label Dec 12, 2022
@github-actions
Copy link
Contributor

Thanks for reporting this issue, don't forget to star this project if you haven't already to help us reach a wider audience.

@jackton1
Copy link
Member

jackton1 commented Dec 12, 2022

@CHarnel curious does .github/workflows/your-workflow.yml include usage of https://github.com/actions/checkout ?

- uses: actions/checkout@v3

@jackton1
Copy link
Member

jackton1 commented Dec 14, 2022

@CHarnel I’ll recommend you setup the https://github.com/actions/checkout with persist-credentials enabled.

@CHarnel
Copy link
Author

CHarnel commented Dec 14, 2022

Hey @jackton1 thanks for the answer, my checkout step looks like this:

- uses: actions/checkout@v3
   with:
     fetch-depth: 0

persist-credentials is true by default, from their docs:

The auth token is persisted in the local git config. This enables your scripts to run authenticated git commands. The token is removed during post-job cleanup. Set persist-credentials: false to opt-out.

...

# Whether to configure the token or SSH key with the local git config
# Default: true
persist-credentials: ''

I just tried setting it to true explicitly and it didn't help.

@CHarnel
Copy link
Author

CHarnel commented Dec 14, 2022

Also tried running the action without any params at all, like this:

- name: Check for changes
  id: changes
  uses: tj-actions/changed-files@v34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants