我正在使用 Enterprise Git 3.0,创建了一个私有存储库。我创建了一个 GitHub 个人访问令牌,将其存储在存储库的机密中,并从工作流程中引用它。PAT 有权读取/写入包。
我创建了下面提到的工作流操作,但是每当我运行时,它都会给出401: Unauthorized。
有人可以指导我缺少什么。
name: Git Deploy
on:
push:
jobs:
publish:
strategy:
matrix:
maven: [ '3.6.3' ]
runs-on: [ self-hosted ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
server-id: github2 # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: install maven # If I don't do this, I was getting mvn not found error
uses: stCarolas/setup-maven@v4.2
with:
maven-version: 3.6.3
- name: read secrets from settings
uses: s4u/maven-settings-action@v2.5.0
with:
servers: |
[{
"id": "github2",
"username": "my github user id (Not email)",
"password": "${{ secrets.PAT }}"
}]
- name: Build and deploy
run: mvn -B deploy
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
GITHUB_USER: "my github user id (Not email)"
链接我指 的是https://docs.github.com/en/actions/publishing-packages/publishing-java-packages-with-maven