簡體   English   中英

如何在 github 工作流中添加 git 憑據

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

題:

如何在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

我是這樣修復的:

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