我有一个带有运行 make 的工作流程的存储库。该存储库有一个我拥有的子模块。我想要做的是如果 make 成功,则在子模块中创建或更新标签。
子模块不可靠,我想跟踪构建正常的最后一个已知版本。
这是我到目前为止的工作流程(k.edu 是子模块):
name: CI
on: # Controls when the workflow will run
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest] #[ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: clang on ${{ matrix.os }}
run: clang -v
- name: build on ${{ matrix.os }}
run: cd k.edu && make
最后,我无法标记子模块,因为工作流程无权更改它。我所做的是将子模块 HEAD 修订版附加到
mac
,这是主模块中跟踪的文件。 然后,下次我获取对 mac
的更改时,我可以运行脚本来标记我机器上的子模块。
name: MacOS build
on: # Controls when the workflow will run
push:
branches: [ "main" ]
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
jobs:
build:
runs-on: macos-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: build
run: if ! grep `cd k.edu && git rev-parse HEAD` mac; then cd k.edu && make; fi
- name: mac add
run: |
if ! grep `cd k.edu && git rev-parse HEAD` mac; then
(cd k.edu && git rev-parse HEAD>>../mac)
git config --global user.name 'github-action'
git config --global user.email '[email protected]'
git add mac; git commit -m "$(date -u)"; git push
fi