2020-10-23 02:43:28 +02:00
|
|
|
name: Cancel previous runs
|
2020-08-03 18:50:13 +02:00
|
|
|
on: [push, pull_request]
|
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
cancel:
|
2020-10-23 02:43:28 +02:00
|
|
|
name: Cancel previous runs
|
2020-08-03 18:50:13 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 3
|
|
|
|
|
|
|
|
# Don't run this job for zulip/zulip pushes since we
|
|
|
|
# want to run those jobs.
|
|
|
|
if: ${{ github.event_name != 'push' || github.event.repository.full_name != 'zulip/zulip' }}
|
|
|
|
|
|
|
|
steps:
|
|
|
|
# We get workflow IDs from GitHub API so we don't have to maintain
|
|
|
|
# a hard-coded list of IDs which need to be updated when a workflow
|
2020-08-11 01:47:44 +02:00
|
|
|
# is added or removed. And, workflow IDs are different for other forks
|
2020-08-03 18:50:13 +02:00
|
|
|
# so this is required.
|
|
|
|
- name: Get workflow IDs.
|
|
|
|
id: workflow_ids
|
2021-06-20 17:59:05 +02:00
|
|
|
continue-on-error: true # Don't fail this job on failure
|
2020-08-03 18:50:13 +02:00
|
|
|
env:
|
|
|
|
# This is in <owner>/<repo> format e.g. zulip/zulip
|
|
|
|
REPOSITORY: ${{ github.repository }}
|
|
|
|
run: |
|
|
|
|
workflow_api_url=https://api.github.com/repos/$REPOSITORY/actions/workflows
|
|
|
|
curl $workflow_api_url -o workflows.json
|
|
|
|
|
|
|
|
script="const {workflows} = require('./workflows'); \
|
|
|
|
const ids = workflows.map(workflow => workflow.id); \
|
|
|
|
console.log(ids.join(','));"
|
|
|
|
ids=$(node -e "$script")
|
|
|
|
echo "::set-output name=ids::$ids"
|
|
|
|
|
2021-06-20 18:15:17 +02:00
|
|
|
- uses: styfle/cancel-workflow-action@0.9.0
|
2021-06-20 17:59:05 +02:00
|
|
|
continue-on-error: true # Don't fail this job on failure
|
2020-08-03 18:50:13 +02:00
|
|
|
with:
|
|
|
|
workflow_id: ${{ steps.workflow_ids.outputs.ids }}
|
|
|
|
access_token: ${{ github.token }}
|