potiuk commented on pull request #20939: URL: https://github.com/apache/airflow/pull/20939#issuecomment-1016214503
> I propose a change to use `--jq` which is used elsewhere in the script rather than piping. Thanks @malthe - we are in the process of rewriting all the scripts to python (including those small snippets) as part of #12282 so let's have minimal changes here. I tested thaahttps://github.com/potiuk/airflow/runs/4865079794?check_suite_focus=true and piping works as expected: ``` if [[ "push" == 'pull_request_target' ]]; then event_filter="event=pull_request&" else branch="${GITHUB_REF#refs/heads/}" event_filter="" fi for cancel_url in $( gh api "/repos/$GITHUB_REPOSITORY/actions/runs?${event_filter}branch=${branch}" | \ jq -r ' .workflow_runs[] | select(.head_sha == $ENV.GITHUB_REGISTRY_PUSH_IMAGE_TAG and .status != "completed") | .cancel_url ' \ ); do # One of these URls will be _this_ workflow, so lets exclude that! [[ $cancel_url == */$thisRun/* ]] && continue echo "Cancelling $cancel_url" gh api -X POST --silent "$cancel_url" done shell: /usr/bin/bash -e {0} env: MOUNT_SELECTED_LOCAL_SOURCES: false FORCE_ANSWER_TO_QUESTIONS: yes CHECK_IMAGE_FOR_REBUILD: true SKIP_CHECK_REMOTE_IMAGE: true DB_RESET: true VERBOSE: true GITHUB_REPOSITORY: potiuk/airflow GITHUB_USERNAME: potiuk CONSTRAINTS_GITHUB_REPOSITORY: apache/airflow GITHUB_TOKEN: *** GITHUB_REGISTRY_PULL_IMAGE_TAG: latest GITHUB_REGISTRY_WAIT_FOR_IMAGE: false INSTALL_PROVIDERS_FROM_SOURCES: true AIRFLOW_LOGIN_TO_GITHUB_REGISTRY: true GITHUB_REGISTRY_PUSH_IMAGE_TAG: 2050e628f8e5fd18b8b13b5c52dcbf3daad003bc branch: thisRun: 1717050085 Cancelling https://api.github.com/repos/potiuk/airflow/actions/runs/1717050086/cancel ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
