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

PAT based access to different account not working in github actions #1824

Open
kombos opened this issue Jul 17, 2024 Discussed in #1823 · 0 comments
Open

PAT based access to different account not working in github actions #1824

kombos opened this issue Jul 17, 2024 Discussed in #1823 · 0 comments

Comments

@kombos
Copy link

kombos commented Jul 17, 2024

Discussed in #1823

Originally posted by kombos July 16, 2024
I'm trying to create a github repo action such that pushing / merging to main branch of this repo A, belonging to github account M, triggers a push of the code to another repo B, belonging to github account N. I've created a PAT in account N, with full access to all repos and all options (just to be sure access isn't the problem), and stored this token value in the secrets of account M. Now i'm using this workflow file

name: Sync to Account N

on:
  push:
    branches:
      - main

jobs:
  sync:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Set up Git
        run: |
          git config --global user.email "actions@github.com"
          git config --global user.name "GitHub Actions"

      - name: Print Git version
        run: git --version

      - name: Add remote target
        run: |
          echo "URL: https://${{ secrets.PATVALUE }}@github.com/accountN/repoB.git"
          git remote add target https://${{ secrets.PATVALUE }}@github.com/accountN/repoB.git
          git remote -v

      - name: Test remote with verbose output
        run: |
          GIT_TRACE=1 GIT_CURL_VERBOSE=1 git ls-remote target

the error coming in 'Test remote with verbose output' is:

un GIT_TRACE=1 GIT_CURL_VERBOSE=1 git ls-remote target
  GIT_TRACE=1 GIT_CURL_VERBOSE=1 git ls-remote target
  shell: /usr/bin/bash -e {0}
09:51:51.607855 git.c:465               trace: built-in: git ls-remote target
09:51:51.608048 run-command.c:657       trace: run_command: GIT_DIR=.git git remote-https target https://***@github.com/accountN/repoB.git
09:51:51.609442 git.c:750               trace: exec: git-remote-https target https://***@github.com/accountN/repoB.git
09:51:51.609477 run-command.c:657       trace: run_command: git-remote-https target https://***@github.com/accountN/repoB.git
09:51:51.614165 http.c:843              == Info: Couldn't find host github.com in the (nil) file; using defaults
09:51:51.616472 http.c:843              == Info:   Trying 140.82.113.4:443...
09:51:51.665886 http.c:843              == Info: Connected to github.com (140.82.113.4) port 443 (#0)
09:51:51.690660 http.c:843              == Info: found 413 certificates in /etc/ssl/certs
09:51:51.690715 http.c:843              == Info: GnuTLS ciphers: NORMAL:-ARCFOUR-128:-CTYPE-ALL:+CTYPE-X509:-VERS-SSL3.0
09:51:51.690742 http.c:843              == Info: ALPN, offering h2
09:51:51.690745 http.c:843              == Info: ALPN, offering http/1.1
09:51:51.741218 http.c:843              == Info: SSL connection using TLS1.3 / ECDHE_RSA_AES_128_GCM_SHA256
09:51:51.743483 http.c:843              == Info:   server certificate verification OK
09:51:51.743495 http.c:843              == Info:   server certificate status verification SKIPPED
09:51:51.743688 http.c:843              == Info:   common name: github.com (matched)
09:51:51.743694 http.c:843              == Info:   server certificate expiration date OK
09:51:51.743698 http.c:843              == Info:   server certificate activation date OK
09:51:51.743707 http.c:843              == Info:   certificate public key: EC/ECDSA
09:51:51.743710 http.c:843              == Info:   certificate version: #3
09:51:51.743720 http.c:843              == Info:   subject: CN=github.com
09:51:51.743726 http.c:843              == Info:   start date: Thu, 07 Mar 2024 00:00:00 GMT
09:51:51.743797 http.c:843              == Info:   expire date: Fri, 07 Mar 2025 23:59:59 GMT
09:51:51.743827 http.c:843              == Info:   issuer: C=GB,ST=Greater Manchester,L=Salford,O=Sectigo Limited,CN=Sectigo ECC Domain Validation Secure Server CA
09:51:51.743838 http.c:843              == Info: ALPN, server accepted to use h2
09:51:51.743862 http.c:843              == Info: Using HTTP2, server supports multiplexing
09:51:51.743865 http.c:843              == Info: Connection state changed (HTTP/2 confirmed)
09:51:51.743872 http.c:843              == Info: Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
09:51:51.743990 http.c:843              == Info: Using Stream ID: 1 (easy handle 0x558945ca1d60)
09:51:51.744012 http.c:790              => Send header, 0000000344 bytes (0x00000158)
09:51:51.744017 http.c:802              => Send header: GET /accountN/repoB.git/info/refs?service=git-upload-pack HTTP/2
09:51:51.744019 http.c:802              => Send header: Host: github.com
09:51:51.744021 http.c:802              => Send header: user-agent: git/2.45.2
09:51:51.744023 http.c:802              => Send header: accept: */*
09:51:51.744041 http.c:802              => Send header: accept-encoding: deflate, gzip, br, zstd
09:51:51.744043 http.c:802              => Send header: authorization: basic <redacted>
09:51:51.744046 http.c:802              => Send header: accept-language: C, *;q=0.9
09:51:51.744048 http.c:802              => Send header: pragma: no-cache
09:51:51.744050 http.c:802              => Send header: git-protocol: version=2
09:51:51.744051 http.c:802              => Send header:
09:51:51.825862 http.c:790              <= Recv header, 0000000013 bytes (0x0000000d)
09:51:51.825943 http.c:802              <= Recv header: HTTP/2 404
09:51:51.825950 http.c:790              <= Recv header, 0000000026 bytes (0x0000001a)
09:51:51.825952 http.c:802              <= Recv header: server: GitHub-Babel/3.0
09:51:51.825968 http.c:790              <= Recv header, 0000000054 bytes (0x00000036)
09:51:51.825970 http.c:802              <= Recv header: content-security-policy: default-src 'none'; sandbox
09:51:51.825974 http.c:790              <= Recv header, 0000000041 bytes (0x00000029)
09:51:51.825976 http.c:802              <= Recv header: content-type: text/plain; charset=UTF-8
09:51:51.825978 http.c:790              <= Recv header, 0000000020 bytes (0x00000014)
09:51:51.825980 http.c:802              <= Recv header: content-length: 21
09:51:51.825982 http.c:790              <= Recv header, 0000000037 bytes (0x00000025)
09:51:51.825984 http.c:802              <= Recv header: date: Tue, 16 Jul 2024 09:51:51 GMT
09:51:51.825986 http.c:790              <= Recv header, 0000000060 bytes (0x0000003c)
09:51:51.825988 http.c:802              <= Recv header: x-github-request-id: DC41:25DB7E:E4A1ADC:130907D7:669642B7
09:51:51.825990 http.c:790              <= Recv header, 0000000023 bytes (0x00000017)
09:51:51.825992 http.c:802              <= Recv header: x-frame-options: DENY
09:51:51.825995 http.c:790              <= Recv header, 0000000002 bytes (0x00000002)
09:51:51.825997 http.c:802              <= Recv header:
09:51:51.826009 http.c:843              == Info: Connection #0 to host github.com left intact
remote: Repository not found.
fatal: repository 'https://github.com/accountN/repoB.git/' not found
Error: Process completed with exit code 128.

I've tried using the PAT locally in terminal and accessing the repo B and it is working, which means PAT is not the problem. Can you please help?

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

1 participant