我的 GitHub Actions 工作流程如下。我正在尝试运行 Gradle 任务以从 .proto 文件生成 Kotlin 文件。生成这些文件后,我想将这些 Kotlin 文件推送到另一个存储库。
这是正在运行的 GitHub Actions:https://github.com/ksharma-xyz/Proto-API/actions/runs/9806185942/job/27077373188
我已经验证,直到
Verify pushed branch
,一切都很好,创建了提交并创建了分支。然而,在任务 Create Pull Request
中,PR 不会被创建,也不会推送任何内容。我需要一些帮助来调试这个。
工作流程文件如下:
name: Generate Kotlin
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
generate-kotlin:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: List directory structure before building
run: ls -R
- name: Generate Protos
run: ./gradlew generateProtos
- name: List directory structure after building
run: ls -R
- name: List generated Kotlin files for debugging
run: ls -R lib/build/generated/source/wire/ || echo "Directory not found"
- name: Upload generated Kotlin files
uses: actions/upload-artifact@v4
with:
name: generated-kotlin-files
path: lib/build/generated/source/wire/**/*.kt
- name: Checkout target repo
uses: actions/checkout@v4
with:
repository: 'ksharma-xyz/Kotlin-Proto'
token: ${{ secrets.TOKEN }}
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: generated-kotlin-files
path: ./generated
- name: List downloaded files
run: ls -R ./generated
- name: Configure Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git config --global init.defaultBranch main
- name: Create a new branch
run: git checkout -b kotlin
- name: Copy generated files to target repo
run: |
mkdir -p kotlin
touch test.txt
cp -r ./generated/* kotlin/
ls -R kotlin/ || echo "Copy failed"
- name: Create Commit
run: |
git add .
git commit -m "Kotlin Files"
- name: Push changes to target repo
run: git push --set-upstream origin kotlin
- name: Verify pushed branch
run: |
git fetch
git checkout kotlin
git log -1
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.TOKEN }}
commit-message: "Add generated Kotlin files from ksharma-xyz/Proto-API"
branch: kotlin
title: "Add generated Kotlin files from main project"
body: "This PR adds the generated Kotlin files from the main project."
base: main
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: ksharma-xyz <[email protected]>
signoff: false
delete-branch: false
draft: false
我解决了,问题是我们不需要单独提交。 PR 任务将自动创建提交。 https://github.com/ksharma-xyz/Proto-API/blob/main/.github/workflows/gen-kotlin.yaml