Dishant Kamble
Dishant Kamble

Reputation: 259

Github Action for mvn deploy parent pom fails

I am trying to create a parent/central pom which I plan to use across all my project implementations as a common point for version management of all dependencies.

To make this central dependency pom available to other projects, I want to create a git package so that other projects can import this central dependency pom from git package.

Currently while running github action to publish package, I get the following error.

Error:  Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project central-java-dependency: Failed to deploy artifacts: Could not find artifact com.dishant:central-java-dependency:pom:1.0.0 in github (https://maven.pkg.github.com/dishantkamble) -> [Help 1]
Error:  
Error:  To see the full stack trace of the errors, re-run Maven with the -e switch.
Error:  Re-run Maven using the -X switch to enable full debug logging.
Error:  
Error:  For more information about the errors and possible solutions, please read the following articles:
Error:  [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Error: Process completed with exit code 1.

Below is my action yml

name: Java CI with Maven

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up JDK 11
      uses: actions/setup-java@v1
      with:
        java-version: 11
    - name: Build with Maven
      run: mvn -B package --file pom.xml
    - name: Publish to GitHub Packages Apache Maven
      run: mvn deploy
      env:
        GITHUB_TOKEN: ${{ github.token }}

My pom contains distributionManagement as follows

<distributionManagement>
    <repository>
        <id>github</id>
        <name>GitHub Dishant Apache Maven Packages</name>
        <url>https://maven.pkg.github.com/dishantkamble</url>
    </repository>
</distributionManagement>

Can someone help to get this central dependency pom deployed to github packages so that my other projects can successfully import this pom as parent dependency.

Upvotes: 3

Views: 1264

Answers (1)

Dishant Kamble
Dishant Kamble

Reputation: 259

I was able to fix this with the following two changes.

maven.yml

name: Java CI with Maven

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up JDK 11
      uses: actions/setup-java@v1
      with:
        java-version: 11
    - name: Build with Maven
      run: mvn -B package --file pom.xml install
    - name: Publish to GitHub Packages Apache Maven
      run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml -DskipTests
      env:
        GITHUB_TOKEN: ${{ github.token }}

pom.xml

update existing distribution management with the repository name

<distributionManagement>
    <repository>
        <id>github</id>
        <name>GitHub Dishant Apache Maven Packages</name>
        <url>https://maven.pkg.github.com/dishantkamble/central-java-dependency</url>
    </repository>
</distributionManagement>

Upvotes: 2

Related Questions