Maven -B deploy, 401 Unauthorized error

Hi guys,
on my workflow I am trying to maven deploy my package, projects compile without problems and on my local computer I can even do mvn package.

this is the workflow:

      - name: Publish package
        run: mvn -B package
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        shell: bash

and I have this error:

Error: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project FireflyLuciferin: Failed to deploy artifacts: Could not transfer artifact org.dpsoftware:FireflyLuciferin:jar:1.4.4 from/to github ( Transfer failed for 401 Unauthorized -> [Help 1]

any idea on how to solve the problem?


You can try using a personal access token (PAT), instead of the GITHUB_TOKEN, to authenticate.

Normally, the permissions of GITHUB_TOKEN are limited to the repository that contains your workflow.

@brightran thanks for the answer,
it’s strange since my code doesn’t changed but now I can’t maven deploy anymore.

Is there a complete examples on how to upload a package to the github packages?
can I do it via the HUB command?

401 error has been solved using this action:
- name: Set up Maven Settings for deploy
uses: s4u/maven-settings-action@v2.1.1