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

ssh: Could not resolve hostname x-access-token: Name does not resolve #1

Closed
MartinX3 opened this issue Oct 18, 2020 · 4 comments
Closed

Comments

@MartinX3
Copy link

MartinX3 commented Oct 18, 2020

From here comes the x-access-token

git remote add origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"

But the origin gets already set by actions/checkout@v2

I think if the project is based on

- uses: actions/checkout@v2
  with:
    fetch-depth: 0

as a needed previous task, it can save code.
It's the standard task by github to checkout the current repo.
And since V2 the fetch-depth: 0 is needed or it will be depth 1 by default, resulting in only a top commit breaking rebasing. (They decide this change because of performance reasons)

Error log:

  with:
    base_ref: q-mr1
    head_branch: MartinX3/lineage-17.1
    github_token: ***
  env:
    upstream: sonyxperiadev/device-sony-pdx201
    rebase_head: MartinX3/lineage-17.1
    rebase_base: q-mr1
/usr/bin/docker run --name e5c359952171f4361477d96ceab5045332ccc_e4ac42 --label 1e5c35 --workdir /github/workspace --rm -e upstream -e rebase_head -e rebase_base -e INPUT_BASE_REF -e INPUT_HEAD_BRANCH -e INPUT_GITHUB_TOKEN -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/android_device_sony_pdx201/android_device_sony_pdx201":"/github/workspace" 1e5c35:9952171f4361477d96ceab5045332ccc  "q-mr1" "MartinX3/lineage-17.1"
+ [[ -n '' ]]
+ BASE_REF=q-mr1
q-mr1
BASE_REF=q-mr1
HEAD_BRANCH=MartinX3/lineage-17.1
Initialized empty Git repository in /github/workspace/_tmp/.git/
+ HEAD_BRANCH=MartinX3/lineage-17.1
+ [[ -z q-mr1 ]]
+ [[ -z MartinX3/lineage-17.1 ]]
+ git check-ref-format --allow-onelevel --normalize q-mr1
++ git check-ref-format --allow-onelevel --normalize q-mr1
+ BASE_REF=q-mr1
+ echo BASE_REF=q-mr1
+ echo HEAD_BRANCH=MartinX3/lineage-17.1
+ mkdir _tmp
+ cd _tmp
+ git init
+ git config user.name MartinX3
+ git config user.email MartinX3@users.noreply.github.com
origin	x-access-token:@github.com/MartinX3-AndroidDevelopment-LineageOS/android_device_sony_pdx201.git (fetch)
origin	x-access-token:@github.com/MartinX3-AndroidDevelopment-LineageOS/android_device_sony_pdx201.git (push)
+ git remote add origin x-access-token:@github.com/MartinX3-AndroidDevelopment-LineageOS/android_device_sony_pdx201.git
+ git remote set-url origin x-access-token:@github.com/MartinX3-AndroidDevelopment-LineageOS/android_device_sony_pdx201.git
+ git remote -v
+ git remote update
Fetching origin
ssh: Could not resolve hostname x-access-token: Name does not resolve
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
error: Could not fetch origin```
@DeeDeeG
Copy link
Owner

DeeDeeG commented Oct 18, 2020

Hi, thanks for the issue report.

I briefly worked on this GitHub Action, realized I didn't need it, then abandoned it. I meant to make this with a less-desirable name, for example with random letters and numbers in the name. Claiming local-git-rebase on the marketplace was an accident. If someone has a better implementation, I'll work with them to transfer the name to them, if that's possible.

As it is, I'm not personally interested in working on this GitHub Action anymore.

@MartinX3
Copy link
Author

Hi, thanks for your explanation. :)

I use a different solution
Maybe useful for other people seeing this issue ticket
Example:

name: repo-sync
on:
  schedule:
  - cron:  "*/15 * * * *"
jobs:
  repo-sync:
    runs-on: ubuntu-18.04
    steps:
    - name: Define variables
      run: |
        echo "upstream=TeamWin/android_bootable_recovery" >> $GITHUB_ENV
        echo "rebase_base=android-9.0" >> $GITHUB_ENV
        echo "rebase_head=MartinX3/android-9.0" >> $GITHUB_ENV
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0
        ref: ${{ env.rebase_head }}
    - name: Define git author for rebase
      run: |
        git config user.email "email@email.com"
        git config user.name "Firstname Lastname"
    - uses: repo-sync/github-sync@v2
      with:
        source_repo: ${{ env.upstream }}
        source_branch: "*"
        destination_branch: "*"
        github_token: ${{ secrets.GITHUB_TOKEN }}
    - run: git rebase origin/${{ env.rebase_base }} ${{ env.rebase_head }}
    - run: git push --force-with-lease

@DeeDeeG
Copy link
Owner

DeeDeeG commented Oct 18, 2020

Technical notes if anyone cares to maintain a similar "rebase" GitHub Action:

Not basing this off of the CheckoutV2 action was on purpose.

Checking out code is very flexible, and git commands are easy and powerful from a bash scripting perspective. We can fetch strictly the exact branch and ref that we need to perform the rebase.

The CheckoutV2 action, if I recall correctly, fetches all branches, which for a large repository with hundreds of branches could be very inefficient.

Perhaps a better fix would be to add a unique remote that doesn't conflict with CheckoutV2.

For example, with the remote local_git_rebase_remote:

git remote add local_git_rebase_remote "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"

@MartinX3
Copy link
Author

Not basing this off of the CheckoutV2 action was on purpose.

Checking out code is very flexible, and git commands are easy and powerful from a bash scripting perspective. We can fetch strictly the exact branch and ref that we need to perform the rebase.

The CheckoutV2 action, if I recall correctly, fetches all branches, which for a large repository with hundreds of branches could be very inefficient.

Perhaps a better fix would be to add a unique remote that doesn't conflict with CheckoutV2.

For example, with the remote local_git_rebase_remote:

git remote add local_git_rebase_remote "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"

Luckily you can use parameters on checkoutV2 to define the checkout depth as example or other things
https://github.com/actions/checkout
And if the branches share the same history it won't downloaded again. :)

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