2

I deployed a Maven package to github according to these instructions. https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages#installing-a-package

This worked.

Now I am installing a second Maven project that depends on the package that I just deployed to the github registry. I keep getting this error.

Error:

 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 

The install should not be searching for the dependency in repo.maven.apache.org. It should be searching in the github repository - where this dependency lives.

According to github's documentation [https://help.github.com/en/github/managing-packages-with-github-packages/using-github-packages-with-github-actions#installing-a-package-using-an-action] there is a way to install packages hosted by GitHub Packages through GitHub Actions that "requires minimal configuration or additional authentication, by using the GITHUB_TOKEN." However, that document does not explain how to achieve this. How do I need to update a github yaml workflow file to use a github package in an action?

Here is my .m2/settings.xml file...

<?xml version="1.0" encoding="UTF-8"?>
<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>

And here is where I reference the package in the pom.xml file of the 2nd project I am attempting to install.

<dependency>
  <groupId>com.the organization name</groupId>
  <artifactId>the package name</artifactId>
  <version>0.8.6</version>
</dependency>

Finally, here is my yaml file for the github action.

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  
GNG
  • 1,341
  • 2
  • 23
  • 50
  • Having a similar problem. Please post an answer if you find one. Here's the best resource I've found: https://stackoverflow.com/questions/59147676/error-code-400-when-trying-to-maven-deploy-to-github-packages-using-github-act – ccleve Dec 19 '19 at 20:17
  • What a coincidence. – GNG Dec 19 '19 at 20:31

1 Answers1

2

You have to create settings.xml during your workflow. So, either manually create this file or use existing action from Marketplace.

Option 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

Option 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

Personally I use option 2 on my project.

fabasoad
  • 1,613
  • 18
  • 20