-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
How to use "git push" ? #28
Comments
The problem is you're setting the origin using ssh:
Just remove that line |
Hi mhart, |
When change to below
I got another error:
|
Again, you're trying to push using an SSH address – you should be using the HTTP address that you cloned the repo with |
See here for how to use an access token: https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token This isn't an issue with this layer – you would have this issue no matter where you're trying to clone or push from, so I'm going to close this |
And it's easier to include the token when you clone – then you don't need to enter it again. https://github.blog/2012-09-21-easier-builds-and-deployments-using-git-over-https-and-oauth/#using-oauth-with-git |
Thank you very much! |
Hi,
Thanks for [git-lambda-layer]!
I want to build a function to commit something to my github.
Under the layer, I can clone/add/commit in /tmp/my-repository folder, but when I try to push the change to origin branch, I run into below issue. Could you help me to resolve the issue?
error:
...
Could not create directory '/home/sbx_user1051/.ssh'.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
...
This is my code
_const { execSync } = require('child_process')
const process = require('process')
const { GITHUB_TOKEN, GITHUB_USERNAME, GITHUB_EMAIL, GITHUB_REPO, PASSWD } = process.env
exports.handler = async (event) => {
const config = {
token: GITHUB_TOKEN,
username: GITHUB_USERNAME,
email: GITHUB_EMAIL,
repo: GITHUB_REPO,
password: PASSWD
}
const gitUrl =
github.com/${config.username}/${config.repo}.git
const execOpt = { encoding: 'utf8', stdio: 'inherit' }
&& ls && cd SI-AutomationTest && echo testxxx>test.txt
&& git config --local user.email ${config.email}
&& git config --local user.name ${config.username}
&& git add test.txt
&& git branch
&& git config --local user.email ${config.email}
&& git config --local user.name ${config.username}
&& git commit -m '[skip ci] hhhaa'
&& git remote -v
&& git config --local user.email ${config.email}
&& git config --local user.name ${config.username}
&& git remote set-url origin git@github.com:${config.username}/${config.rep}.git
&& git config --local user.email ${config.email}
&& git config --local user.name ${config.username}
&& git push -u origin main`, execOpt)
}_
The text was updated successfully, but these errors were encountered: