Hey I've been trying to make my github actions deploy github packages after building and testing my changes but whatever I try I keep getting the following error:
[INFO]
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ topfind-common ---
[INFO] Uploading to github: https://maven.pkg.github.com/topfind/topfindscraper/com/topfind/topfind-common/1.121/topfind-common-1.121.jar
[INFO] Uploading to github: https://maven.pkg.github.com/topfind/topfindscraper/com/topfind/topfind-common/1.121/topfind-common-1.121.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.077 s
[INFO] Finished at: 2020-08-26T14:01:59Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project topfind-common: Failed to deploy artifacts: Could not find artifact com.topfind:topfind-common:jar:1.121 in github (https://maven.pkg.github.com/topfind/topfindscraper) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project topfind-common: Failed to deploy artifacts: Could not find artifact com.topfind:topfind-common:jar:1.121 in github
The tests pass without problems and I have the following in my workflow file:
name: Build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 13
uses: actions/setup-java@v1
with:
java-version: 13
- name: Get user
run: echo 'The username is' ${{ github.actor }}
- name: Build with Maven
env:
USERNAME: ${{ github.actor }}
PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B -e deploy --file pom.xml --settings settings.xml
- uses: actions/delete-package-versions@v1
with:
package-name: 'com.topfind.topfind-scraper'
My pom file has a distributionManagement that points to the repository. Everything works fine when I do mvn deploy locally and it doesn't ask for anything else. Does anyone know what I'm doing wrong or what I'm missing?
Without being able to see your pom file, i'm thinking that the setup needs some slight adjustments. Per your statement that your local build is working properly then my thoughts are to look at your pipeline setup.
Instead of passing password just pass the token. Exact example on how to setup the workflow for publishing can be found here https://docs.github.com/en/actions/language-and-framework-guides/publishing-java-packages-with-maven
Distribution manager should have the following if not already
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/topfind/topfindscraper</url>
</repository>
</distributionManagement>
And your workflow steps should be as follows
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 13
- name: Publish package
run: mvn -B deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NOTE: Make sure that your github token as read/write access to packages to make sure the deploy is allowed
UPDATE 1
Per request in comments, here is the setup for creating a token for publishing
https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token
Token needs to have access to repo as well if it is a private repo. Otherwise. you just need the permissions below depending if you want your token to allow read, write, or delete when dealing with github packages.
https://docs.github.com/en/packages/publishing-and-managing-packages/about-github-packages

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With