我根据这些说明将Maven软件包部署到了github。 https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages#installing-a-package
这行得通。
现在,我正在安装第二个Maven项目,该项目取决于我刚刚部署到github注册表的软件包。我不断收到此错误。
错误:
The POM for com.xxxxxxx:0.8.6 is missing, no dependency information available github packages
Failure to find com.xxxxxxx.xxxxxxx:jar:7.7 in https://repo.maven.apache.org/maven2
安装程序不应在repo.maven.apache.org中搜索依赖项。它应该在github存储库中搜索-这种依赖关系所在的地方。
根据github的文档[https://help.github.com/en/github/managing-packages-with-github-packages/using-github-packages-with-github-actions#installing-a-package-using-an-action],有一种方法可以通过GitHub Actions安装由GitHub Packages托管的软件包,“通过使用GITHUB_TOKEN,需要最少的配置或其他身份验证”。但是,该文档没有说明如何实现此目的。我该如何更新github yaml工作流文件以在动作中使用github包?
这是我的.m2 / 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">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers>
<server>
<id>github</id>
<username>myGithubUsername</username>
<password>GithubPersonalAccessToken</password>
</server>
</servers>
<mirrors/>
<proxies/>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>github</id>
<name>GitHub myGithubUsername Apache Maven Packages</name>
<url>https://maven.pkg.github.com/myGithubUsername /nameOfGithubRepositoryContainingTheMavenPackageIAmIncluding</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles/>
</settings>
这是我在尝试安装的第二个项目的pom.xml文件中引用软件包的位置。
<dependency>
<groupId>com.the organization name</groupId>
<artifactId>the package name</artifactId>
<version>0.8.6</version>
</dependency>
最后,这是我的github动作的yaml文件。
name: BuildOnWikiEdit
on:
gollum:
branches:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run a one-line script
run: echo Hello, world!
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
- name: Build
run: mvn install
答案 0 :(得分:1)
您必须在工作流程中创建settings.xml
。因此,您可以手动创建此文件,也可以使用Marketplace中的现有操作。
选项1:
- name: 'Create settings.xml'
run: |
touch ~/.m2/settings.xml
echo '<settings><servers><server><id>github</id><username>${{ secrets.GITHUB_USERNAME }}</username><password>${{ secrets.GITHUB_PASSWORD }}</password></server></servers></settings>' > ~/.m2/settings.xml
- name: Build
run: mvn install
选项2:
- name: 'Create settings.xml'
uses: whelk-io/maven-settings-xml-action@v4
with:
servers: '[{"id": "github", "username": "${{ secrets.GITHUB_USERNAME }}", "password": "${{ secrets.GITHUB_PASSWORD }}"}]'
- name: Build
run: mvn install
我个人在项目中使用选项2。