简体   繁体   中英

`API_TOKEN_GITHUB` not recognized with `copy_file_to_another_repo_action` GitHub workflow

I am using the copy_file_to_another_repo_action GitHub workflow from dmnemec ( https://github.com/dmnemec/copy_file_to_another_repo_action ) to push a file from one repo that I own to another repo that I own (here is my workflow ).

The workflow succeeds until it tries to push the commit, at which points it fails with message "Invalid username or password":

Pushing git commit
+ git push -u origin HEAD:master
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/rempsyc/starter-academic.git/'

Yet, I have created a GitHub secret called API_TOKEN_GITHUB (like in the workflow file) in the source repo that pushes the file:

在此处输入图像描述

The token has the following permissions:

在此处输入图像描述

I've tried both a fine-grained token and classic token with appropriate permissions, with the same result. Those are the permissions for the fined-grained token (only for the destination repo, where the file needs to be uploaded):

在此处输入图像描述

Because the workflow uses the API_TOKEN_GITHUB with env: instead of with: , I tried using an environment secret instead, with the same result:

在此处输入图像描述

Is there something obvious I am missing?

This is the same question as: Github action to push build folder to a different repo . However, it has no accepted answer (and the current answer also hasn't worked for me). There is also How to commit and push to a private repo(A), from a different repo(B), in github actions workflow (B), using personal access token but I am following the same steps and still facing this issue.

Edit:

I tested my token as per the troubleshooting steps listed here ( https://cpina.github.io/push-to-another-repository-docs/troubleshooting.html ) and the token works as expected: I was able to create a branch and push to it.

Note that I forgot to mention that I've changed the destination branch to master from the original workflow ( destination_branch: 'master' ) since the default was main.

The issue in my case was that I had created the secret in the destination repo instead of the source repo. Swapping those two fixed the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM