问题描述
我在为我和一些朋友建立适当的构建链时遇到一些麻烦.因此,我分叉了两个回购协议,即正式的ghidra和ghidra-ci.ghidra-ci是一个构建您的ghidra分支的存储库,当您挑选一些公关文件时,您可以添加一些尚未添加到官方ghidra存储库中的东西.
I'm having some trouble setting up a proper build chain for me and some friends.So, I forked two repos, the official ghidra and ghidra-ci.ghidra-ci is an repo which builds your fork of ghidra, when you cherry-pick some pr's so, you can add some things which aren't added to the official ghidra repo yet.
因此,当ghidra存储库更新时,ghidra-ci应该构建ghidra存储库.到目前为止,我设法在ghidra-ci本身是updatet时进行构建.我用过
So, ghidra-ci should build the ghidra repo when the ghidra repo is updated.So far I managed to get it to build when ghidra-ci itself is updatet. I used
name: Ghidra Build
on: [push, pull_request]
(仅是构建作业之后)
所以,我知道这是错误的.我删除了 on:
行,但是我想要一个 on:
行,我只是将 on粘贴:[workflow_dispatch]
.不知道这是否行得通.
So, I know this is wrong.I deleted the on:
line, but I it wants a on:
line, I just pasted on: [workflow_dispatch]
in. I don't know if this is gonna work.
我有一个名为检查新提交"的工作流程
I have a workflow called "Check for new commits"
name: Check for new commits
on:
schedule:
- cron: '30 12 * * *'
workflow_dispatch:
inputs: {}
jobs:
# Ensure all steps use a common revision
check:
name: Check for new commits since last release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
repository: Lockna/Ghidra
- name: Check for new commits
id: check
run: |
LAST_REL_NAME=$(curl --silent "https://api.github.com/repos/${{github.repository}}/releases/latest" | jq .name)
LAST_REL_COMMITID=$(echo $LAST_REL_NAME | grep -oP "\(\K\w+(?=\))")
COMMIT_HASH_SHORT=$(git rev-parse --short HEAD)
COMMIT_HASH_LONG=$(git rev-parse HEAD)
echo "Latest commit is $COMMIT_HASH_LONG"
if [[ "$LAST_REL_NAME" == *"$COMMIT_HASH_SHORT"* ]]; then
echo "No commits since last release $LAST_REL_NAME"
else
echo "Found new commits since $LAST_REL_NAME. Triggering ci."
echo ::set-output name=trigger::true
echo ::set-output name=rev::$COMMIT_HASH_LONG
echo ::set-output name=lastrev::$LAST_REL_COMMITID
fi
- name: Trigger build
if: steps.check.outputs.trigger
uses: benc-uk/[email protected]
with:
workflow: "Ghidra Build"
repo: Lockna/ghidra-ci
token: ${{secrets.PAT_TOKEN}}
inputs: '{ "rev": "${{steps.check.outputs.rev}}", "prevRev": "${{steps.check.outputs.lastrev}}" }'
因此,此工作流程应检查(是否我在更新Ghidra本身时触发,但我发现这并没有按照我的意愿进行)是否有一些更改以及是否有一些应该触发"Ghidra Build"工作流程.为了进行测试,我手动运行了此构建
so, this workflow should check (I would prefer that it triggers when I'm updating the ghidra itself, but I have found out that this doesn't work out as I would like to) if there are some changes and if there are some it should trigger the "Ghidra Build" workflow. For testing I run this build manually
Run benc-uk/[email protected]
with:
workflow: Ghidra Build
repo: Lockna/ghidra-ci
token: ***
inputs: { "rev": "c1a1674214007bf467dd90f6d80fda453d25b16c", "prevRev": "133d6c2" }
Workflow id is: 3932827
Error: Unexpected inputs provided
那是我得到的错误信息.我不知道我还能尝试什么来完成这项工作.如果有人有解决方案,它可以在更新ghidra repo时真正建立在该解决方案上,那么我想听听.
That's the error message I get.I don't know what else I could try to get this work.If someone has a solution where it really builds when ghidra repo is updated, I would like to hear that.
推荐答案
您可以让ghidra-ci收听 repository_dispatch
事件:
You could have ghidra-ci listen to the repository_dispatch
event:
name: Listener for ghidra
on:
repository_dispatch:
workflow_dispatch:
jobs:
dump:
runs-on: ubuntu-20.04
steps:
- name: Dump event payload
run: |
jq . "$GITHUB_EVENT_PATH"
workflow_dispatch
在那里,因此您可以手动触发工作流以进行测试. run
步骤只是转储事件有效负载,您可以将其替换为所需的任何构建步骤;您可以通过按事件类型进行过滤(例如
workflow_dispatch
is there so you can manually trigger the workflow for test purposes. The run
step just dumps the event payload, and you can replace that with whatever build steps you want; you can further filter which events should trigger by filtering by event type, such as
on:
workflow_dispatch:
types:
- mytrigger
在ghidra中,您可以通过向/repos/{owner}/ghidra-ci/dispatches
发送POST请求来生成该事件,例如使用 GitHub CLI :
In ghidra, you can generate that event by sending a POST request to /repos/{owner}/ghidra-ci/dispatches
, for example using the GitHub CLI:
name: Notify ghidra-ci
on:
push:
workflow_dispatch:
jobs:
notify:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Create repository dispatch event
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
gh api repos/:owner/ghidra-ci/dispatches \
--raw-field event_type=mytrigger
同样, workflow_dispatch
触发器在那里允许手动触发.
Again, the workflow_dispatch
trigger is there to allow manual triggering.
GitHub CLI抱怨它是否不在Git存储库中运行,因此我们首先签出存储库,然后发送POST请求.
The GitHub CLI complains if it isn't run in a Git repository, so we first check out the repo, and then send the POST request.
对于身份验证,您必须使用至少具有 public_repo
范围的个人访问令牌;仅 $ GITHUB_TOKEN
无效.
For authentication, you must use a personal access token with at least public_repo
scope; $GITHUB_TOKEN
alone doesn't work.
为 event_type
设置的值在事件有效负载中显示为 action
.
The value set for event_type
shows up as action
in the event payload.
这篇关于Github Action触发另一个回购更新(push,pull_request)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!