Error on Github Packages for maven install '-SNAPSHOT' maven artifact

I all,
I have 2 private repos:

  • _https://github.com/ORGANIZATION/repo1
  • _https://github.com/ORGANIZATION/repo2

in the repo1, the .github/workflows/maven.yml is the following:

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 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Compile
      run: mvn -B deploy --file pom-ci.xml -DskipTests=true
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

and the pom-ci.xml (a part of) is:

<groupId>com.organization</groupId>
    <artifactId>artifact1</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <distributionManagement>
        <repository>
            <id>github</id>
            <name>GitHub OWNER Apache Maven Packages</name>
            <url>https://maven.pkg.github.com/ORGANIZATION/repo1</url>
        </repository>
    </distributionManagement>

If the workflow run everything it’s ok and, under Packages, I can find my package:

  • com.organization.artifact1 0.0.1-SNAPSHOT
    with 2 files:
    • artifact1-0.0.1-20201231.303000-1.jar
    • artifact1-0.0.1-20201231.303000-1.pom

Now repo2. In this one the .github/workflows/maven.yml is the following:

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 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: maven-settings-temporary
      uses: InstaCode/maven-settings-xml-action@v9
      env:
       ACTION_TOKEN:  ${{ secrets.ACTION_TOKEN }}
      with:
        repositories: '[{ "id": "my-server", "url": "https://maven.pkg.github.com/ORGANIZATION/repo1", "snapshots": { "enabled": "true" }}]'
        servers: '[{ "id": "my-server", "username": "my_username", "password": "$ACTION_TOKEN" }]'
    - name: Build & Deploy
      run: mvn -B install deploy --file pom-ci.xml -DskipTests=true 
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

and the pom-ci.xml (a part of) is:

    <groupId>com.organization</groupId>
    <artifactId>artifact2</artifactId>
    <version>0.0.1</version>

    <dependencies>
        <dependency>
            <groupId>com.organization</groupId>
            <artifactId>artifact1</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
    </dependencies>

As you can see the artifact1, produced by the workflow of the repo1, is a dependency of the repo2

If the workflow run raise an error during the ‘Build & Deploy’ step and the error is

Failed to execute goal on project rools-engine: Could not resolve dependencies for project com.organization:artifact2:jar:0.0.1: Failed to collect dependencies at com.organization:artifact1:jar:0.0.1-SNAPSHOT: Failed to read artifact descriptor for com.organization:artifact1:jar:0.0.1-SNAPSHOT: Could not transfer artifact com.organization:artifact1:pom:0.0.1-SNAPSHOT from/to artifact1 (https://maven.pkg.github.com/ORGANIZATION/repo1): Transfer failed for https://maven.pkg.github.com/organization/repo1/com/organization/artifact1/0.0.1-SNAPSHOT/artifact1-0.0.1-SNAPSHOT.pom 400 Bad Request

If I try to copy and paste this URL
https://maven.pkg.github.com/organization/repo1/com/organization/artifact1/0.0.1-SNAPSHOT/artifact1-0.0.1-SNAPSHOT.pom
in a browser it does not actually exist, but if instead I use the name of the pom file I find under the Packages section

https://maven.pkg.github.com/organization/repo1/com/organization/artifact1/0.0.1-SNAPSHOT/artifact1-0.0.1-20201231.303000-1.pom
I am able to download the file successfully

What am I doing wrong?

Thanks for everything, Danilo

Summary

This text will be hidden