繁体   English   中英

github 操作:使用 rebase 从上游更新子模块

[英]github actions: update submodules from upstream with rebase

我想更新我的存储库子模块,推送到它们各自的分支,然后将更改提交到我的主存储库并推送它。

这是我的 github 操作 yml:

---
name: Auto Update Submodules
# yamllint disable-line rule:truthy
on:
  push:
  # schedule:
  #   # Run every Wednesday at 4 AM.
  #   - cron: "0 4 * * WED"
jobs:
  auto-update:
    runs-on: ubuntu-latest
    steps:
      # Create private key to access private repos.
      - uses: webfactory/ssh-agent@v0.5.3
        with:
          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
      - uses: actions/checkout@v2
        with:
          ref: '15.0'
          submodules: true
          ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
          persist-credentials: true
      - name: Update submodules from origin
        run: |
          git submodule update --recursive --remote --merge --init --rebase
      - name: Update from upstream and commit
        run: |
          git config --global user.name 'bot'
          git config --global user.email 'bot@users.noreply.github.com'
          cd src/odoo
          git checkout 15.0
          git remote add upstream git@github.com:odoo/odoo.git
          git fetch upstream 15.0
          git rebase upstream/15.0
          git push
          cd ../enterprise
          git checkout 15.0
          git remote add upstream git@github.com:odoo/enterprise.git
          git fetch upstream 15.0
          git rebase upstream/15.0
          git push
          cd ../..
          git add .
          git commit -m "[SUB] odoo/enterprise" || echo "No changes to commit"
          git push origin 15.0

这是触发动作时我得到的结果:

  git submodule update --recursive --remote --merge --init --rebase
  shell: /usr/bin/bash -e {0}
  env:
    SSH_AUTH_SOCK: /tmp/ssh-VxFJiDzXtsoG/agent.2130
    SSH_AGENT_PID: 2131
Rebasing (1/1)
warning: Cannot merge binary files: stock_barcode/static/img/barcodes_demo.pdf (HEAD vs. 944ae3a4 ([I18N] Update translation terms from Transifex))
CONFLICT (add/add): Merge conflict in worksheet/i18n/sv.po
Auto-merging worksheet/i18n/sv.po
CONFLICT (add/add): Merge conflict in worksheet/i18n/de.po
Auto-merging worksheet/i18n/de.po
CONFLICT (add/add): Merge conflict in website_twitter_wall/i18n/zh_TW.po
Auto-merging website_twitter_wall/i18n/zh_TW.po
CONFLICT (add/add): Merge conflict in website_twitter_wall/i18n/vi.po
Auto-merging website_twitter_wall/i18n/vi.po
CONFLICT (add/add): Merge conflict in website_twitter_wall/i18n/th.po
Auto-merging website_twitter_wall/i18n/th.po
...
...
Error: Process completed with exit code 2.

如果我只从上游获取更改并使用它来提交主存储库,它会更新它。 但是随后的工作流程中断了,因为它找不到那些提交(直接来自上游存储库)。

我尝试从本地上游(从我的 PC)更新我的子模块,它工作正常。 没有冲突,没有错误,(甚至不需要强制推送它,因为我没有任何自定义更改):

git fetch upstream 15.0
git rebase upstream/15.0
git push

src/odoosrc/enterprise是子模块的路径。

我对 github 行为的行为有什么不同做错了什么?

难道它只得到浅拷贝而事情因此而破裂?

通过单独更新子模块(作为普通存储库)然后从子模块获取推送更改来解决它:

---
name: Auto Update Submodules
# yamllint disable-line rule:truthy
on:
  push:
  # schedule:
  #   # Run every Wednesday at 4 AM.
  #   - cron: "0 4 * * WED"
jobs:
  auto-update:
    runs-on: ubuntu-latest
    steps:
      # Create private key to access private repos.
      - uses: webfactory/ssh-agent@v0.5.3
        with:
          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
      - uses: actions/checkout@v2
        with:
          repository: my/odoo
          ref: '15.0'
          ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
      # Sync submodules (separately).
      - name: Sync odoo repo
        run: |
          git remote add upstream git@github.com:odoo/odoo.git
          git fetch upstream 15.0
          git rebase upstream/15.0
          git push
      - uses: actions/checkout@v2
        with:
          repository: my/enterprise
          ref: '15.0'
          ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
      - name: Sync enterprise repo
        run: |
          git remote add upstream git@github.com:odoo/enterprise.git
          git fetch upstream 15.0
          git rebase upstream/15.0
          git push
      # Update synced submodules on main repo.
      - uses: actions/checkout@v2
        with:
          ref: '15.0'
          submodules: true
          ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
      - name: Update submodules from origin
        run: |
          git submodule update --recursive --remote --merge --init --rebase
      - name: Commit updated submodules.
        run: |
          git config --global user.name 'bot'
          git config --global user.email 'bot@users.noreply.github.com'
          git add .
          git commit -m "[SUB] odoo/enterprise" || echo "No changes to commit"
          git push origin 15.0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM