【问题标题】:How can I add git credentials in github workflow如何在 github 工作流程中添加 git 凭据
【发布时间】:2020-01-22 13:12:23
【问题描述】:

问题:

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

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

【问题讨论】:

  • 这是什么 CI?特拉维斯 CI?
  • github 工作流程和操作

标签: git github automation continuous-deployment


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    我是这样解决的:

    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
    

    【讨论】:

      猜你喜欢
      • 2020-08-24
      • 2017-03-29
      • 2020-02-26
      • 1970-01-01
      • 2021-07-25
      • 1970-01-01
      • 2021-04-17
      • 1970-01-01
      • 2020-10-14
      相关资源
      最近更新 更多