首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试发布到文件包时,Github操作工作流(专用存储库)挂起

尝试发布到文件包时,Github操作工作流(专用存储库)挂起
EN

Stack Overflow用户
提问于 2021-07-28 00:09:52
回答 2查看 235关注 0票数 1

私有存储库的Github操作工作流:

在IntelliJ项目中,OrionDAO是Orion项目的一个方面,因此必须首先运行。

OrionDAO Pom的一部分如下:

代码语言:javascript
复制
<project xmlns="http://maven.apache.org/POM/4.0.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>uk.co.xxxx.orionDAO</groupId>
   <artifactId>orionDAO</artifactId>
   <packaging>jar</packaging>
   <name>Orion Model</name>
   <description>Orion </description>
   <version>25.1.3</version>

……….


   <distributionManagement>
      <repository>
         <id>github</id>
         <name>Apache Maven Packages</name>
         <url>https://maven.pkg.github.com/xxxx/Orion_CICD</url>
      </repository>
   </distributionManagement>
</project>

Orion Pom的一部分如下:

4.0.0

代码语言:javascript
复制
<groupId>uk.co.xxxx.orion</groupId>
<artifactId>orion</artifactId>
<version>25.1.3</version>
<packaging>war</packaging>

<name>Orion</name>
<description>Orion </description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.4.2</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>15</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <hapi-fhir-version>4.2.0</hapi-fhir-version>

</properties>

<dependencies>
    <dependency>
        <groupId>uk.co.xxxx.orionDAO</groupId>
        <artifactId>orionDAO</artifactId>
        <version>25.1.3</version>
        <scope>provided</scope>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>
    </plugins>
    <finalName>orion</finalName>
</build>

<distributionManagement>
    <repository>
        <id>github</id>
        <name>GitHub ReedInPartnership Apache Maven Packages</name>
        <url>https://maven.pkg.github.com/xxxx/Orion_CICD</url>
    </repository>
</distributionManagement>

在部署步骤之前,这一切都运行得很好。

然后它就会停在那里。

我添加了permissions: step,但仍然挂起。

代码语言:javascript
复制
# This workflow will trigger when a PR is closed and will put out a message
# dependant upon Orion being built and deployed to the Master branch

name: Master Workflow - PR message output and build and deploy
on:
  pull_request:
    types: closed
    branches:
      - master

permissions:
  contents: read
  packages: write

jobs:
  merge_job:
    # this job will only run if the PR has been merged
    if: github.event.pull_request.merged == true
    runs-on: windows-latest
    steps:
      - run: |
          echo PR #${{ github.event.number }} has been merged

  close_job:
    # this job will only run if the PR has been closed without being merged
    if: github.event.pull_request.merged == false
    runs-on: windows-latest
    steps:
      - run: |
          echo PR #${{ github.event.number }} has been closed without being merged

  deploy_job:
    # this job will only run if the PR has been merged i.e merge-job completed successfully
    needs: merge_job
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK 16 for now
        uses: actions/setup-java@v2
        with:
          java-version: '16'
          distribution: 'adopt'

      - name: Set up Maven
        uses: stCarolas/setup-maven@v4
        with:
          maven-version: 3.6.3

      - name: Cache Maven packages
        uses: actions/cache@v2
        with:
          path: ~/.m2
          key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-m2

      - name: 'Create settings.xml'
        uses: whelk-io/maven-settings-xml-action@v4
        with:
          repositories: '[{ "id": "github", "url": "https://maven.pkg.github.com/ReedInPartnership/Orion_CICD" }]'
          servers: '[{"id": "github", "username": "${{ secrets.GITHUB_USERNAME }}", "password": "${{ secrets.GITHUB_PASSWORD }}"}]'

      - name: Install Jespa
        run: mvn install:install-file "-Dfile=Orion\jespa-1.2.6.jar" "-DgroupId=jespa" "-DartifactId=jespa" "-Dversion=1.2.6" "-Dpackaging=jar" "-DgeneratePom=true"

      - name: Build with Maven (Orion DAO)
        run: mvn -B install --file Orion_DAO/pom.xml

      - name: Build with Maven (Orion)
        run: mvn -B install --file Orion/pom.xml

      - name: Publish to GitHub Packages Orion
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: mvn --batch-mode --file Orion/pom.xml deploy

输出:上传jar和pom到github时挂起

* UPDATE *

这是我作为合并请求的创建者和合并它的人完成的,我想这可能就是它被挂起的原因。因此,我让其他人(审阅者)进行合并,现在它没有挂起,但我得到了以下错误

代码语言:javascript
复制
Error:  Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project orion: Failed to deploy artifacts: Could not transfer artifact uk.co.reed.orion:orion:war:25.1.3 from/to github (https://maven.pkg.github.com/xxxx/Orion_CICD): Transfer failed for https://maven.pkg.github.com/xxxx/Orion_CICD/uk/co/reed/orion/orion/25.1.3/orion-25.1.3.war 401 Unauthorized -> [Help 1]
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/MojoExecutionException
Error: Process completed with exit code 1.

* UPDATE2 *

我现在已经得到了另一个具有管理员权限的审阅者来合并这个,我们回到了刚刚挂在maven部署步骤中的工作流程!!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-08-03 07:34:33

最后,我创建了一个发布工作流,然后它创建了包。似乎包只在release事件类型上创建,尽管我在我读过的所有文档中都找不到这一点。

代码语言:javascript
复制
# This workflow will build and publish to Github Packages on release

name: Master Workflow - Build and Publish to GitHub Packages
on:
  release:
    types: [created]
jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v2
        with:
          java-version: '16'
          distribution: 'adopt'

      - name: Install Jespa
        run: mvn install:install-file "-Dfile=Orion\jespa-1.2.6.jar" "-DgroupId=jespa" "-DartifactId=jespa" "-Dversion=1.2.6" "-Dpackaging=jar" "-DgeneratePom=true"

      - name: Build with Maven (Orion DAO)
        run: mvn -B install --file Orion_DAO/pom.xml

      - name: Build with Maven (Orion)
        run: mvn -B install --file Orion/pom.xml

      - name: Publish package
        run: mvn --batch-mode --file Orion/pom.xml deploy
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
票数 0
EN

Stack Overflow用户

发布于 2021-09-29 06:29:14

可以将settings.xml添加到与pom.xml相同的项目根文件夹中

然后,您可以像这样添加步骤:

代码语言:javascript
复制
- name: Build with Maven
   env:
      USENAME: ${{github.actor}}
      PASSWORD: ${{ secrets.GITHUB_TOKEN }}
   run: mvn -B clean package --settings settings.xml

settings.xml的内容:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">

    <servers>
        <server>
            <id>github</id>
            <username>${env.USERNAME}</username>
            <password>${env.PASSWORD}</password>
        </server>

    </servers>

</settings>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68548344

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档