【发布时间】:2021-03-23 20:15:55
【问题描述】:
我有两个不同的存储库。一个用于库,另一个用于需要来自其他存储库的库的应用程序。当我运行第二个存储库的 Github 操作时,我得到了一个
Authentication failed for https://maven.pkg.github.com/XXXX/YYYY/file.pom 401 Unauthorized
我已经尝试过更改 maven 设置(当我更改本地 maven 设置并安装我的应用程序时,这是有效的):
- uses: DamianReeves/write-file-action@v1.0
with:
path: ~/.m2/settings.xml
contents: ${{ secrets.MAVEN_SETTINGS }}
write-mode: overwrite
Settings.xml 文件是:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>USERNAME</username>
<password>TOKEN</password>
</server>
</servers>
</settings>
我也尝试过使用 maven-settings-action:
- name: Configure Maven
uses: s4u/maven-settings-action@v2.2.0
with:
servers: |
[{
"id": "imdb-github",
"username": "${{ secrets.MAVEN_USERNAME }}",
"password": "${{ secrets.MAVEN_PASSWORD }}"
}]
我也尝试使用 GITHUB_TOKEN 但没有任何运气。
需要该库的项目的 pom.xml 文件有一个 repositories 部分,如下所示:
<repositories>
<repository>
<id>imdb-github</id>
<url>https://maven.pkg.github.com/user/repo</url>
</repository>
</repositories>
有人知道解决办法吗?
【问题讨论】:
标签: maven github-actions github-package-registry