joshp
joshp

Reputation: 836

Access Organization repo on Github using Personal Access Token inside Bash script

I'm trying to clone a repo using the following syntax inside a bash script

git clone "https://oauth2:[TOKEN]@github.com/[organization]/$reponame.git $REPOPATH/$reponame"

and I get the following error:

Cloning into 'protos-cusum_hmm-python'...
fatal: unable to access 'https://github.com/[organization]/protos-cusum_hmm-python.git /opt/protolangs/protos-cusum_hmm-python/': The requested URL returned error: 400

when I clone directly from command line git clone https://github.com/[organizaiton]/protos-cusum_hmm-python.git it works fine (presumable because it's using my cached credentials)

Any suggestions?

Edit:

Removed quotations around url (git clone https://oauth2:[TOKEN]@github.com/[organization]/$reponame.git $REPOPATH/$reponame) and now getting

remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/fluxusinc/protos-cusum_hmm-python.git/'

EDIT2:

When hardcoded with token:

git clone "https://[email protected]/[organization]/"$reponame".git" $REPOPATH/$reponame

it works, so seems like it's a problem with the YAML

- name: Run proto builder and deploy to repos
        env:
          P_TOKEN: ${{ secrets.REPO_TOKEN }}
        run: |
           chmod +x "${GITHUB_WORKSPACE}/build.sh"
           "$GITHUB_WORKSPACE/build.sh"
        shell: bash

Upvotes: 1

Views: 638

Answers (1)

joshp
joshp

Reputation: 836

much thanks to @torek....

turns out for whatever reason I had to put the secret in the repo rather than the organization and it worked... not sure why that was the case because github is showing it overriding

github secret

MORE INFO:

was able to figure out by setting the secret ACTIONS_STEP_DEBUG to true from here.

yielded

##[debug]Evaluating: secrets.REPO_TOKEN_GRPC
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'REPO_TOKEN_GRPC'
##[debug]=> null
##[debug]Result: null

showing that the token was empty for whatever reason

Upvotes: 1

Related Questions