【发布时间】:2022-10-25 15:41:10
【问题描述】:
我需要一些帮助我在 IntelliJ IDEA 中有一个 gradle 项目,我正在尝试使用 github 操作通过 github 自动化 gradle。我用于 github 操作的 .yml 文件包含
name: CI - build and test
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Grant execute permission for gradlew
working-directory: ./project
run: chmod +x ./gradlew
- name: Build
working-directory: ./project
run: ./gradlew build
- name: Test
working-directory: ./project
run: ./gradlew test
- name: Update Website
working-directory: ./project
run: ./gradlew deployReports
错误来自最后一步- name: Update Website working-directory: ./project run: ./gradlew deployReports
这是位于我的 build.gradle 文件中的 deployReports 函数
task deployReports (dependsOn: 'copyWebsite'){
group = "Reporting"
description 'Copies reports to the website repo and pushes to github'
doLast{
def pagesDir = "$buildDir/gh-pages"
exec{
workingDir = 'build/gh-pages'
commandLine = ['git', 'add', '.']
}
exec{
workingDir = 'build/gh-pages'
commandLine = ['git', 'commit', '-m', 'Updating-webpages']
}
exec{
workingDir = 'build/gh-pages'
commandLine = ['git', 'push']
}
}
}
错误来自这一行commandLine = ['git', 'commit', '-m', 'Updating-webpages']
我不确定如何解决这个问题,因为 git 安装正确,我仍然可以提交并从终端推送自己。任何见解都会很棒!
【问题讨论】:
-
您确定您的 CI 设置正确吗? 128通常与授权问题有关。
-
这可能是因为您没有在工作流程中配置 git 用户。在提交之前尝试将
git config user.name github-actions和git config user.email github-actions@github.com之类的内容添加到您的函数中,看看它是否能解决您的问题。
标签: github gradle github-actions