My GitbHub action job keeps failing at the "git pull" script with the following error:
err: fatal: could not read Username for ‘https://github.com’: No such device or address.
Here’s what my yaml file looks like
name: Deploy to DigitalOcean
on:
# run it on push to the develop repository branch
push:
branches: [develop]
# run it during pull request
pull_request:
branches: [develop]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ssh-key: ${{ secrets.GH_SSH_KEY }}
fetch-depth: 0
ref: develop
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: yarn install
- name: Build application
run: yarn build
- name: Set up Git
env:
GIT_AUTH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
git config --global user.email "${{ secrets.GH_USER_EMAIL }}"
git config --global user.name "${{ secrets.GH_USERNAME }}"
- name: Deploy application to DigitalOcean
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_SSH_HOST }}
username: ${{ secrets.STAGING_SSH_USERNAME }}
key: ${{ secrets.STAGING_SSH_KEY }}
script: |
cd my-app
git switch develop
git pull
echo "${{ secrets.STAGING_ENV_FILE }}" > .env
npm run reload
I am not sure how to solve this, been at this for hours now.
I tried adding the ssh url for the repository to Checkout code step
- name: Checkout code
uses: actions/checkout@v2
with:
ssh-key: ${{ secrets.GH_SSH_KEY }}
fetch-depth: 0
repository: [email protected]:My-CoPilot/my_copilot_backend.git
ref: develop
But that didn’t work either 🙁
2
Answers
Thanks VonC for your answer.
It turned out that when I logged into my droplet console and ran the "git pull" command, it prompted me to authenticate the github user. After doing that, running "git pull" subsequently went without a hitch or need for authentication.
So that's all I had to do really.
When I re-ran the failed job, the "git pull" command this time around did not throw an error, but ran successfully.
The ‘
could not read Username for 'https://github.com':
means:In other words:
actions/checkout@v2
(using an SSH URL) that you have added is executed on a GitHub runner, a Azure server on Microsoft/GitHub sideappleboy/[email protected]
will connect to a remote server (no longer a GitHub runner) and execute yourgit pull
there.The local repository in ‘
~remoteUser/my-app
‘ on that remote server is configured to use HTTPS.You could at least add in your
script:
commands: