尝试发布到包时,GitHub操作工作流(私有回购)挂起
私有存储库的Github操作工作流:
在IntelliJ项目中,OrionDAO是Orion项目的一个方面,因此必须首先运行。
部分OrionDAO POM如下:
<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>
猎户座POM的一部分如下:
4.0.0
<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>
在部署步骤之前,这一切都运行良好。
然后它就停在那里。
我添加了权限:步骤,但仍挂起。
# 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=Orionjespa-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时挂起
*更新* *更新* *更新*
我是合并请求的创建者,也是合并请求的合并者,我想这可能就是它挂起的原因。因此,我让其他人(审阅者)进行合并,现在它没有挂起,但我收到了以下错误
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.
*更新2*
*更新2*
*更新2*
我现在已经让另一位具有管理员访问权限的审阅者来合并这一点,我们回到了刚刚挂起的maven部署步骤中的工作流!!
解决方案
最后,我创建了一个发布工作流,然后它创建了包。似乎包只在发布事件类型上创建,尽管我在我阅读的所有文档中都找不到这一点。
# 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=Orionjespa-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 }}
相关文章