简体   繁体   English

Github 动作推送 java 工件到 github 回购

[英]Github action push java artifact to github repo

I have a Github repo project using GitHub actions with a docker file used to build the SpringBoot Java project.我有一个 Github 回购项目,它使用 GitHub 操作和一个 docker 文件用于构建 SpringBoot ZD523878880E1EA2238177A 项目。
I want to download packages from the Github repo for custom artifacts from GitHub repo and also be able upload artifact to it.我想从 Github 存储库下载来自 GitHub 存储库的自定义工件的软件包,并且还可以将工件上传到它。

So I followed the link Configuring Apache Maven for use with GitHub Packages by adding the section to a settings.xml file:所以我点击链接Configuring Apache Maven for use with GitHub Packages通过将部分添加到设置中。

  <activeProfiles>
    <activeProfile>github</activeProfile>
  </activeProfiles>

  <profiles>
    <profile>
      <id>github</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
        <repository>
          <id>github</id>
          <name>GitHub OWNER Apache Maven Packages</name>
          <url>https://maven.pkg.github.com/OWNER/REPOSITORY</url>
        </repository>
      </repositories>
    </profile>
  </profiles>

  <servers>
    <server>
      <id>github</id>
      <username>USERNAME</username>
      <password>${GITHUB_TOKEN}</password>
    </server>
  </servers>
</settings>

To publish the package from the dockerfile build I added the following to my pom.xml:要从 dockerfile 版本发布 package,我将以下内容添加到我的 pom.xml 中:

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

The following is the content of my dockerfile:以下是我的dockerfile的内容:

FROM adoptopenjdk/maven-openjdk10 as build
WORKDIR /app
ADD pom.xml /app/pom.xml
ADD src /app/src    
ADD settings.xml /root/.m2/settings.xml
RUN ["mvn", "clean", "install", "deploy"]

Is it possible to deploy from the dockerfile to Github repo?是否可以从 dockerfile 部署到 Github 存储库? Somehow the deploy piece does not seem to work.不知何故,部署部分似乎不起作用。 I have tried few times but not sure what's wrong with my sections.我尝试了几次,但不确定我的部分有什么问题。 Currently this is my error in my docker build:目前这是我在 docker 构建中的错误:

Could not transfer metadata com.chg.sa:demo-sa-java-service:1.0-SNAPSHOT/maven-metadata.xml from/to github ( https://maven.pkg.github.com/OWNER/REPOSITORY ): Not authorized -> [Help 1] Could not transfer metadata com.chg.sa:demo-sa-java-service:1.0-SNAPSHOT/maven-metadata.xml from/to github ( https://maven.pkg.github.com/OWNER/REPOSITORY ): Not授权 -> [帮助 1]

I got the push working using Dockerfile building by passing in the github token as build arg and switching the owner and repo name to their values.我通过将 github 令牌作为构建 arg 并将所有者和仓库名称切换为它们的值来使用 Dockerfile 构建进行推送。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM