fix(dashmate): failing doctor with drive metrics enabled #935
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Manage runs | |
on: | |
pull_request: | |
types: | |
- closed | |
jobs: | |
cancel-merged-or-closed-pr-runs: | |
name: Cancel runs for merged or closed PRs | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: octokit/request-action@v2.x | |
id: get_active_workflows | |
with: | |
route: GET /repos/{owner}/{repo}/actions/runs?status=in_progress&event=pull_request | |
owner: dashpay | |
repo: platform | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract running workflow ids | |
id: extract_workflow_ids | |
run: | | |
current_branch=${GITHUB_HEAD_REF} | |
# loop thru the workflows found & filter out ones that are not on PRs pointing to this branch | |
workflow_ids=$(echo '${{ steps.get_active_workflows.outputs.data }}' | \ | |
jq '.workflow_runs | map({id, head_branch})' | \ | |
jq 'map(select(.head_branch == "'$current_branch'")) | map(.id)' | \ | |
jq 'join(",")') | |
# strip the wrapping quote marks before passing to next step | |
echo 'WORKFLOW_IDS='$(echo $workflow_ids | tr -d '"') >> $GITHUB_ENV | |
- name: Cancel active workflow runs | |
run: | | |
for id in ${WORKFLOW_IDS//,/ } | |
do | |
echo "Cancelling workflow with id: $id" | |
# use curl here as I have no idea how to use a github action in a loop | |
curl \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/repos/${{ github.repository }}/actions/runs/$id/cancel | |
done |