Home > Back-end >  GitHub Actions : How to fix Non-readable error
GitHub Actions : How to fix Non-readable error

Time:06-09

Introduction

I'm currently creating a GitHub Actions that build and publish library automatically to Maven Central and GitHub Packages.

https://github.com/MathieuSoysal/Java-maven-library-publisher

Problematic

When I use it for one of my projects, I have this error :

Run ***/[email protected]
Run actions/setup-java@v2
Trying to resolve the latest version from remote
Resolved latest version as 17.0.3 7
Trying to download...
Downloading Java 17.0.3 7 (Adopt-Hotspot) from https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.3+7/OpenJDK17U-jdk_x64_linux_hotspot_17.0.3_7.tar.gz ...
Extracting Java archive...
/usr/bin/tar xz --warning=no-unknown-keyword -C /home/runner/work/_temp/e14dd782-78c0-4b6e-b676-853ba934cb4f -f /home/runner/work/_temp/82c80710-6101-4e89-93f3-4e0ff007ff0b
Java 17.0.3 7 was downloaded
Setting Java 17.0.3 7 as the default
Java configuration:
  Distribution: adopt
  Version: 17.0.3 7
  Path: /opt/hostedtoolcache/Java_Adopt_jdk/17.0.3-7/x64
Creating settings.xml with server-id: ossrh
Writing to /home/runner/.m2/settings.xml
Importing private gpg key
Run mvn -B package --file pom.xml
POM file pom.xml specified with the -f/--file command line argument does not exist
[INFO] Scanning for projects...
Error: ] Some problems were encountered while processing the POMs:
[FATAL] Non-readable POM /home/runner/work/CodinGame-Puzzles-stats-library/CodinGame-Puzzles-stats-library/pom.xml: /home/runner/work/CodinGame-Puzzles-stats-library/CodinGame-Puzzles-stats-library/pom.xml (No such file or directory) @ 
 @ 
Error:  The build could not read 1 project -> [Help 1]
Error: 
Error:    The project  (/home/runner/work/CodinGame-Puzzles-stats-library/CodinGame-Puzzles-stats-library/pom.xml) has 1 error
Error:      Non-readable POM /home/runner/work/CodinGame-Puzzles-stats-library/CodinGame-Puzzles-stats-library/pom.xml: /home/runner/work/CodinGame-Puzzles-stats-library/CodinGame-Puzzles-stats-library/pom.xml (No such file or directory)
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/ProjectBuildingException
Error: Process completed with exit code 1.

https://github.com/MathieuSoysal/CodinGame-Puzzles-stats-library/runs/6759689588?check_suite_focus=true

Affected code

name: Java maven library publisher
author: "Mathieu Soysal (@MathieuSoysal)"
description: "Build automatically Java Maven library and publish it to GitHub Packages and Maven Central."
branding:
  icon: "package"
  color: "gray-dark"

inputs:
  nexus-username:
    description: "Nexus username"
    required: true
  nexus-password:
    description: "Nexus password"
    required: true
  gpg-private-key:
    description: "GPG private key"
    required: true
  gpg-passphrase:
    description: "GPG passphrase"
    required: true
  github-token:
    description: "GitHub token"
    required: true
  # Java version to use
  java-version:
    description: "Java version to use"
    required: true
    default: "17"
  # Library version
  library-version:
    description: "Library version"
    required: false
    default: ""

runs:
  using: "composite"
  steps:
    - name: Set up JDK 17 for deploy to OSSRH
      uses: actions/setup-java@v2
      with:
        distribution: "adopt"
        java-version: ${{ inputs.java-version }}
        server-id: ossrh
        server-username: ${{ inputs.nexus-username }}
        server-password: ${{ inputs.nexus-password }}
        gpg-private-key: ${{ inputs.gpg-private-key }}
        gpg-passphrase: ${{ inputs.gpg-passphrase }}

    - name: Build with Maven
      run: mvn -B package --file pom.xml
      shell: bash

    - name: Update package version
      if: ${{ inputs.library-version != '' }}
      run: mvn versions:set -DnewVersion=${{ inputs.library-version }}
      shell: bash

    - name: Prepare Maven environnement with Java 17 for deployment to OSSRH
      run: export MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED"
      shell: bash

    - name: Publish to Apache Maven Central
      run: mvn deploy -PossrhDeploy
      shell: bash
      env:
        MAVEN_USERNAME: ${{ inputs.nexus-username }}
        MAVEN_CENTRAL_TOKEN: ${{ inputs.nexus-password }}
        MAVEN_GPG_PASSPHRASE: ${{ inputs.gpg-passphrase }}

    - name: Set up JDK 17 for deploy to github packages
      uses: actions/setup-java@v2
      with:
        distribution: "adopt"
        java-version: ${{ inputs.java-version }}
        server-id: github

    - name: Publish to GitHub Packages Apache Maven
      run: mvn deploy -PgithubDeploy
      shell: bash
      env:
        GITHUB_TOKEN: ${{ inputs.github-token }}

Code that used GitHub Actions

name: Java library publisher
on:
  release:
    types: [created]
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Maven Library build and publish
        uses: MathieuSoysal/[email protected]
        with:
          nexus-username: ${{ secrets.NEXUS_USERNAME }}
          nexus-password: ${{ secrets.NEXUS_PASSWORD }}
          gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
          gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
          github-token: ${{ secrets.GITHUB_TOKEN }}
          java-version: 17

Question

Does anyone know how we can fix the Non-Readable error for a created GitHub Actions?

CodePudding user response:

You need simply to add actions/checkout@v3 before your Java setup.
The final Yaml file like this:

name: Java maven library publisher
author: "Mathieu Soysal (@MathieuSoysal)"
description: "Build automatically Java Maven library and publish it to GitHub Packages and Maven Central."
branding:
  icon: "package"
  color: "gray-dark"

inputs:
  nexus-username:
    description: "Nexus username"
    required: true
  nexus-password:
    description: "Nexus password"
    required: true
  gpg-private-key:
    description: "GPG private key"
    required: true
  gpg-passphrase:
    description: "GPG passphrase"
    required: true
  github-token:
    description: "GitHub token"
    required: true
  # Java version to use
  java-version:
    description: "Java version to use"
    required: true
    default: "17"
  # Library version
  library-version:
    description: "Library version"
    required: false
    default: ""

runs:
  using: "composite"

  steps:
    - name: Checkout
      uses: actions/checkout@v3

    - name: Set up JDK 17 for deploy to OSSRH
      uses: actions/setup-java@v2
      with:
        distribution: "adopt"
        java-version: ${{ inputs.java-version }}
        server-id: ossrh
        server-username: ${{ inputs.nexus-username }}
        server-password: ${{ inputs.nexus-password }}
        gpg-private-key: ${{ inputs.gpg-private-key }}
        gpg-passphrase: ${{ inputs.gpg-passphrase }}

    - name: Build with Maven
      run: mvn -B package --file pom.xml
      shell: bash

    - name: Update package version
      if: ${{ inputs.library-version != '' }}
      run: mvn versions:set -DnewVersion=${{ inputs.library-version }}
      shell: bash

    - name: Prepare Maven environnement with Java 17 for deployment to OSSRH
      run: export MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED"
      shell: bash

    - name: Publish to Apache Maven Central
      run: mvn deploy -PossrhDeploy
      shell: bash
      env:
        MAVEN_USERNAME: ${{ inputs.nexus-username }}
        MAVEN_CENTRAL_TOKEN: ${{ inputs.nexus-password }}
        MAVEN_GPG_PASSPHRASE: ${{ inputs.gpg-passphrase }}

    - name: Set up JDK 17 for deploy to github packages
      uses: actions/setup-java@v2
      with:
        distribution: "adopt"
        java-version: ${{ inputs.java-version }}
        server-id: github

    - name: Publish to GitHub Packages Apache Maven
      run: mvn deploy -PgithubDeploy
      shell: bash
      env:
        GITHUB_TOKEN: ${{ inputs.github-token }}

CodePudding user response:

I think it is nothing to do with Github Action but more of reference to the POM file while using -f

Check this out:

Non Readable Pom File - Maven.

  • Related