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

Support for authenticating to private action repos #49

Open
danpowell88 opened this issue Aug 18, 2024 · 2 comments
Open

Support for authenticating to private action repos #49

danpowell88 opened this issue Aug 18, 2024 · 2 comments

Comments

@danpowell88
Copy link

Using this inside of an organisation where the actions repo are internal or private the scripts are unable to clone the git repo as it expects them to be public.

Any chance we can add a way to specify auth details to push through to git?

I may take a look if/when I get a chance but wanted to get any ideas on implementation first

This is what happens currently

EXEC: git remote add origin https://github.com/my-org/actions.git
EXEC: git -c protocol.version=2 fetch --tags --no-recurse-submodules origin
fatal: could not read Username for 'https://github.com/': No such device or address
ERROR: Command exited with code 128
@danpowell88 danpowell88 changed the title Support for authenticating toprivate action repos Support for authenticating to private action repos Aug 18, 2024
@alec-drw
Copy link

alec-drw commented Sep 11, 2024

Also looking for this. Updating the remoteAdd function with:

await exec.exec('git', ['-c', `http.extraHeader=Authorization: Bearer ${github_token}`, 'remote', 'add', 'origin', `${github_prefix}${owner}/${repo}.git`])

Change the error to:

EXEC: git -c http.extraHeader=Authorization: *** remote add origin https://git.enterprise.com/actions/setup-docker-environment.git
EXEC: git -c protocol.version=2 -c http.extraHeader=Authorization: *** fetch --tags --no-recurse-submodules origin
fatal: unable to access 'https://git.enterprise.com/actions/setup-docker-environment.git/': The requested URL returned error: 400

But still no success 👎

@alec-drw
Copy link

alec-drw commented Sep 16, 2024

@danpowell88 FWIW I did figure this out - I ended up making a decent amount of edits to support caching of actions that are stored on an on-prem Github Enterprise Server instance, however I had to setup auth for public github.com too. As long as your github token has the required permissions this should work for you:

- name: Run add action script
  env:
    GITHUB_TOKEN_EXTERNAL: ${{ secrets.GITHUB_CLOUD_PAT }}
  run: |
    git config --local user.email "[email protected]"
    git config --local user.name "github-actions"

    export GITHUB_TOKEN=$GITHUB_TOKEN_EXTERNAL
    git config --global "url.https://${GITHUB_TOKEN}@github.com.insteadof" "https://github.com"
    
    ./script/add-action.sh ${{ inputs.action-author }}/${{ inputs.action-name }}

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

No branches or pull requests

2 participants