Where do I put my username for 'https://github.com' to pull from my private repo through github actions?

Viewed 174

I have a private repo and I'm trying to set my github actions so that when I push my code onto github, my workflow pulls the code from github to the server (ubuntu). For my secrets I have the host set to the IP address, username set as root, and a ssh key in private key.

When I run this the 'git pull' request fails and gives me an error: "fatal: could not read Username for 'https://github.com': No such device or address". Obviously it wants my github username and password which I can do when I manually run this in the command line, but how do I insert it for github actions?

name: Pull code, rebuild files and restart pm2 processes

on:
  push:
    branches: [master]

jobs:
  update:
    runs-on: ubuntu-latest
    steps:
    - name: Rebuild server
      uses: garygrossgarten/github-action-ssh@release
      with:
        command: |
          cd testwebsite.com
          git pull
          npm install
          npx tsc
          cd client
          npm run build
          pm2 restart server client
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        privateKey: ${{ secrets.PRIVATE_KEY}}
1 Answers

You can use pre-built action for this operation, actions\checkout@v1. https://github.com/actions/checkout

Your file should look something similar to this

on:
  pull_request:
  push:
    branches: 
      - development
jobs:
  primary:
    runs-on: ubuntu-latest
    env:
      working-directory: ./
    steps:
      - uses: actions/checkout@v1
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: 12.x
      - name: install Dependencies
        run: yarn install
        working-directory: ${{env.working-directory }}
Related