dmnemec / copy_file_to_another_repo_action

This GitHub Action copies a file from the current repository to a location in another repository
Apache License 2.0
182 stars 201 forks source link

Authorization fails when 2FA is enabled #60

Closed license-yml closed 2 years ago

license-yml commented 2 years ago
+ '[' -z <output-file-path> ]
+ '[' -z github.com ]
+ '[' -z  ]
+ INPUT_DESTINATION_BRANCH=main
+ OUTPUT_BRANCH=main
Cloning destination git repository
+ mktemp -d
+ CLONE_DIR=/tmp/tmp.fmApGh
+ echo 'Cloning destination git repository'
+ git config --global user.email <user-email>
+ git config --global user.name <user-name>
+ git clone --single-branch --branch main ***github.com/<org-name>/<repo-name>.git /tmp/tmp.fmApGh
Cloning into '/tmp/tmp.fmApGh'...
warning: redirecting to https://github.com/<org-name>/<repo-name>.git/
+ '[' '!' -z  ]
+ DEST_COPY=/tmp/tmp.fmApGh/<file-destination>
+ echo 'Copying contents to git repo'
Copying contents to git repo
+ mkdir -p /tmp/tmp.fmApGh/<file-destination>
+ '[' -z  ]
+ cp -R <output-file-path> /tmp/tmp.fmApGh/<file-destination>
+ cd /tmp/tmp.fmApGh
+ '[' '!' -z  ]
Adding git commit
+ '[' -z 'Commit <file-to-be-copied>' ]
+ echo 'Adding git commit'
+ git add .
+ git status
+ grep -q 'Changes to be committed'
+ git commit --message 'Commit changes'
[main 8a84aa4] Commit <file-to-be-copied>
+ echo 'Pushing git commit'
+ git push -u origin HEAD:main
 1 file changed, 36 insertions(+)
 create mode 100644 <file-destination>
Pushing git commit
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/<org-name>/<repo-name>.git/

I get above error message while trying to push a file to destination repo in same org. The user has write access to both repositories and secrets(PAT, email, username) are added on both sides. Excluding 'delete', PAT has all access. Can you let me know if I'm missing something in configuration or this action can't be used when 2FA is enabled in organisation settings.

Thanks!