首页 > 解决方案 > GitHub Actions 无法通过 SSH 加载,尽管它似乎使用 ssh-access 工作

问题描述

我正在执行 github 操作以在我的 PR 上运行测试并推送,但我无法确保测试能够访问我的私人存储库。

我已经测试了我在本地使用的 SSH 凭据,它们 100% 有效。

https://github.com/webfactory/ssh-agent

这是我正在使用的 SSH 代理。

这是我的 github 操作

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
  push:
    branches: 
      - master
      - release/*
  pull_request:
    branches:
      - master
      - release/*

jobs:
  build:

    runs-on: ubuntu-latest

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

    steps:
    - uses: actions/checkout@v2
    - uses: webfactory/ssh-agent@v0.4.0
      with:
        ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: npm ci
    - run: npm run build --if-present
    - run: npm test

它似乎没有尝试使用它获得的 SSH 密钥

在此处输入图像描述

标签: githubsshgithub-actionsssh-agent

解决方案


由于https://github.com/Tixpire/tixpire-server似乎是私有的,因此您需要使用PAT(个人访问令牌)来访问它。
另请参阅操作/结帐问题 95

它是一个 HTTPS URL,所以没有多少 SSH 密钥可以工作:你需要一个 SSH URL (git@github.com:Tixpire/tixpire-server


推荐阅读