gpt4 book ai didi

github - 是否有任何 github 操作可以为子模块更新创建拉取请求?

转载 作者:行者123 更新时间:2023-12-04 13:29:42 25 4
gpt4 key购买 nike

基本上,我得到了一个包含子模块的 github 存储库,然后我希望能够定期检查子模块更新的工作流程,然后将它们从另一个分支拉入默认分支。
是否有任何操作或任何可以自动更新它们并创建类似于依赖机器人在子模块被推送到其默认分支时更新依赖项的拉取请求的操作?

最佳答案

事实证明,我能够为此做一些工作(没有合并拉取请求到子模块更新的限制,这些更新不调用默认分支中的工作流我必须创建一个 github bot 帐户以用于个人访问 token ,因为我不知道如何制作一个私有(private)机器人应用程序,然后只给我一个个人访问 token ):

name: Submodule Update

on:
push:
branches: [ main ]
tags:
- '*'
schedule:
- cron: '20 * * * *'

jobs:
submodule-update:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
# we need the submodules.
submodules: recursive
- name: Update submodule.
run: git submodule update --remote
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITSYNC_TOKEN }}
commit-message: Updated submodule.
committer: GitHub <noreply@github.com>
author: [bot name] <[bot url part to noreply]@users.noreply.github.com>
signoff: true
branch: app/updated-submodules
base: main
delete-branch: true
title: '[insert submodule name here] Update submodule.'
body: |
Update report
- Auto-generated by [create-pull-request][1]

[1]: https://github.com/peter-evans/create-pull-request
draft: false
然后对于拉取请求工作流程,我会执行以下操作:
name: .NET Core (build pull request)

on: [pull_request]

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
# we need the submodules.
submodules: recursive

# build, test, and package the projects here.

- uses: hmarr/auto-approve-action@v2.0.0
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' || [check the repository admins too here] || github.actor == 'the bot's username I made as well here'
with:
# I think this must stay the same since github's token does not affect any of the flow.
github-token: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions-ecosystem/action-add-labels@v1
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' || [check the repository admins too here] || github.actor == 'the bot's username I made as well here'
with:
github_token: ${{ secrets.GITSYNC_TOKEN }}
labels: |
enhancement
automerge
然后最后我也使用它进行自动合并(将其限制为仅标签以仅在构建完成时部署它以减少额外的不需要的状态检查。
name: automerge
on:
pull_request:
types:
- labeled
status: {}
jobs:
automerge:
runs-on: ubuntu-latest
steps:
- name: automerge
uses: "pascalgn/automerge-action@v0.13.0"
env:
# to get workflow invokes after merge.
GITHUB_TOKEN: "${{ secrets.GITSYNC_TOKEN }}"
MERGE_REMOVE_LABELS: "automerge"
MERGE_METHOD: "squash"
MERGE_RETRIES: "6"
MERGE_RETRY_SLEEP: "10000"
UPDATE_METHOD: "rebase"
这会导致完全自动化的拉取请求更新子模块,就像旧的dependabot在合并到github之前对依赖项更新所做的那样。
注意:从那时起操作版本可能已经更新,我强烈建议设置dependabot 以保持操作最新以及您的正常依赖项更新,以确保它们始终正常工作。

关于github - 是否有任何 github 操作可以为子模块更新创建拉取请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65853756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com