Open bxb100 opened 2 years ago
\n
的文件只会输出第一行, 用如下方式解决:
ERR_MSG=$(cat err.log)
ERR_MSG="${ERR_MSG//'%'/'%25'}"
ERR_MSG="${ERR_MSG//$'\n'/'%0A'}"
ERR_MSG="${ERR_MSG//$'\r'/'%0D'}"
echo "::error title=err::$ERR_MSG"
Anyway to check the error message and retry?
||
来 retry 命令, 但是我这个 shell 着实繁琐又不想写个 sh 文件, 忽略^12> file
输出错误信息, 判断^3, 然后利用 workflow 的 API 来重新调用[^2], 调用代码如下
failure()
标识 此 job 中存在失败${{ secrets.GH_PAT }}
注意给 workflow 的权限workflow_id
目前好像只能通过 list workflows 的 API 来获取exit 1
continue-on-error: true
^4 会导致 failure
判断失效
name: Failed if: ${{ failure() }} run: | if grep -q 'errorMessage' err.log; then curl --location --request POST 'https://api.github.com/repos/xxx/xxx/actions/workflows/xxxx/dispatches' \ --header 'Accept: application/vnd.github.v3+json' \ --header 'Authorization: token ${{ secrets.GH_PAT }}' \ --header 'Content-Type: application/json' \ --data-raw '{ "ref": "main", "inputs": { "xxx": "${{github.event.inputs.xxx}}" } }' fi
注意一点, workflow_call
不允许自己调用自己(错误信息如下), 所以可能只有上述方法可行
error parsing called workflow "bxb100/xxx/.github/workflows/download.yml@main": job "retry" calls workflow "bxb100/xxx/.github/workflows/download.yml@main", but doing so would exceed the limit on called workflow depth of 2
[^2]: https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event Create a workflow dispatch event
see https://gist.github.com/bxb100/d2fedcb3cdc897062ee03920d6ae83be
gh
upload to the release
- name: Upload
run: |
until gh release upload --clobber --repo ${{ github.repository }} ${{ github.event.inputs.tag }} *.zip *.tar.gz; do
echo "Attempt $((++attempts)) to upload release artifacts failed. Will retry in 20s"
sleep 20
done
timeout-minutes: 10
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
https://github.com/actions/toolkit/blob/e98bae803b6520b2a331f66011d812c3af8bf6ae/packages/cache
At the beginning, I tried to understand this path as a specified file glob expression, like this: ~/.m2/repository/**
but correct the way is upload directory like this: ~/.m2/repository/*/*/*
So don't miss the point of what your need
一般来说, GitHub action 如果要上传到 marketplace 的话需要生成 dist 目录, 但是可以通过 https://github.com/JasonEtco/build-and-tag-action 项目自动生成 dist 然后自动上传 (去除了非 dist, action.xml, 仓库大小减少了~~)
注意默认 github.token
权限问题: https://github.com/JasonEtco/build-and-tag-action/issues/40 注意一定要有 write
权限...
If you using a useable workflow, input with env
will cause an error (test secrets
, needs.xx.outputs.xxx
working now)^1
The workflow is not valid. xxxx: Unrecognized named-value: 'env'.
My work on https://github.com/BurtonQin/lockbud/pull/49 show that problems
solve the problem using a config like this:
with:
rust_version: ${{ needs.test.outputs.rust_version }}