简体   繁体   English

如何在 github 工作流中添加 git 凭据

[英]How can I add git credentials in github workflow

Question:题:

How can I add git credentials in the GitHub workflow?如何在GitHub工作流中添加 git 凭据?

nodejs.yml nodejs.yml

name: Node CI

on:
  push:
    branches: 
      - master
      - gh-pages 

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [8.x, 10.x]

    steps:
    - uses: actions/checkout@v1
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: npm run deploy
      run: |
        npm install
        npm run deploy  
      env:
        CI: t

I fixed it like this:我是这样修复的:

nodejs.yml nodejs.yml

name: Node CI

on:
  push:
    branches: 
      - master

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [8.x]

    steps:
    - uses: actions/checkout@v1

    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}

    - uses: fusion-engineering/setup-git-credentials@v2
      with:
        credentials: ${{secrets.GIT_CREDENTIAL}}

    - name: npm run deploy
      run: |
        export GIT_USER=${{secrets.GIT_USER}}
        git config --global user.name "$GIT_USER"
        git config --global user.email "hi@pushe.co"
        npm install
        npm run deploy  
      env:
        CI: true

它有一个功能,请查看github secrets

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM