119ea8026Sopenharmony_ciname: status 219ea8026Sopenharmony_cion: 319ea8026Sopenharmony_ci workflow_run: 419ea8026Sopenharmony_ci workflows: [test] 519ea8026Sopenharmony_ci types: [completed] 619ea8026Sopenharmony_ci 719ea8026Sopenharmony_cijobs: 819ea8026Sopenharmony_ci status: 919ea8026Sopenharmony_ci runs-on: ubuntu-18.04 1019ea8026Sopenharmony_ci steps: 1119ea8026Sopenharmony_ci # custom statuses? 1219ea8026Sopenharmony_ci - uses: dawidd6/action-download-artifact@v2 1319ea8026Sopenharmony_ci continue-on-error: true 1419ea8026Sopenharmony_ci with: 1519ea8026Sopenharmony_ci workflow: ${{github.event.workflow_run.name}} 1619ea8026Sopenharmony_ci run_id: ${{github.event.workflow_run.id}} 1719ea8026Sopenharmony_ci name: status 1819ea8026Sopenharmony_ci path: status 1919ea8026Sopenharmony_ci - name: update-status 2019ea8026Sopenharmony_ci continue-on-error: true 2119ea8026Sopenharmony_ci run: | 2219ea8026Sopenharmony_ci ls status 2319ea8026Sopenharmony_ci for s in $(shopt -s nullglob ; echo status/*.json) 2419ea8026Sopenharmony_ci do 2519ea8026Sopenharmony_ci # parse requested status 2619ea8026Sopenharmony_ci export STATE="$(jq -er '.state' $s)" 2719ea8026Sopenharmony_ci export CONTEXT="$(jq -er '.context' $s)" 2819ea8026Sopenharmony_ci export DESCRIPTION="$(jq -er '.description' $s)" 2919ea8026Sopenharmony_ci # help lookup URL for job/steps because GitHub makes 3019ea8026Sopenharmony_ci # it VERY HARD to link to specific jobs 3119ea8026Sopenharmony_ci export TARGET_URL="$( 3219ea8026Sopenharmony_ci jq -er '.target_url // empty' $s || ( 3319ea8026Sopenharmony_ci export TARGET_JOB="$(jq -er '.target_job' $s)" 3419ea8026Sopenharmony_ci export TARGET_STEP="$(jq -er '.target_step // ""' $s)" 3519ea8026Sopenharmony_ci curl -sS -H "authorization: token ${{secrets.BOT_TOKEN}}" \ 3619ea8026Sopenharmony_ci "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/runs/` 3719ea8026Sopenharmony_ci `${{github.event.workflow_run.id}}/jobs" \ 3819ea8026Sopenharmony_ci | jq -er '.jobs[] 3919ea8026Sopenharmony_ci | select(.name == env.TARGET_JOB) 4019ea8026Sopenharmony_ci | .html_url 4119ea8026Sopenharmony_ci + "?check_suite_focus=true" 4219ea8026Sopenharmony_ci + ((.steps[] 4319ea8026Sopenharmony_ci | select(.name == env.TARGET_STEP) 4419ea8026Sopenharmony_ci | "#step:\(.number):0") // "")'))" 4519ea8026Sopenharmony_ci # update status 4619ea8026Sopenharmony_ci curl -sS -X POST -H "authorization: token ${{secrets.BOT_TOKEN}}" \ 4719ea8026Sopenharmony_ci "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/statuses/` 4819ea8026Sopenharmony_ci `${{github.event.workflow_run.head_sha}}" \ 4919ea8026Sopenharmony_ci -d "$(jq -n '{ 5019ea8026Sopenharmony_ci state: env.STATE, 5119ea8026Sopenharmony_ci context: env.CONTEXT, 5219ea8026Sopenharmony_ci description: env.DESCRIPTION, 5319ea8026Sopenharmony_ci target_url: env.TARGET_URL}' \ 5419ea8026Sopenharmony_ci | tee /dev/stderr)" 5519ea8026Sopenharmony_ci done 56