Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/prettier-2.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed Oct 3, 2023
2 parents 698896a + 96c8030 commit 42e641e
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 24 deletions.
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

19 changes: 19 additions & 0 deletions README.md
Expand Up @@ -145,6 +145,24 @@ jobs:
all_but_latest: true
```

### Advanced: Skip runs that are in progress

Some workflows may be dangerous to cancel when they are in progress. If you want to play safe and cancel only workflows that are in state `waiting`, most likely waiting for approval to be deployed in a protected environment, use `only_status` to only cancel runs with a specific status.

```yml
name: Cancel
on: [push]
jobs:
cancel:
name: 'Cancel Previous Runs'
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: styfle/cancel-workflow-action
with:
only_status: 'waiting'
```

### Advanced: Token Permissions

No change to permissions is required by default. The instructions below are for improved control over of those permissions.
Expand Down Expand Up @@ -174,4 +192,5 @@ _Note_ : This is typical when global access is set to be restrictive. Only this
- Run `yarn install`
- Edit `./src/index.ts`
- Run `yarn build`
- Run `yarn format`
- Commit changes including `./dist/index.js` bundle
5 changes: 4 additions & 1 deletion action.yml
Expand Up @@ -17,9 +17,12 @@ inputs:
default: ${{ github.token }}
required: false
all_but_latest:
description: "Cancel all actions but the last one"
description: "Optional - Cancel all actions but the most recent one."
required: false
default: 'false'
only_status:
description: "Optional - Cancel runs with a specific status, such as `waiting`."
required: false
runs:
using: 'node16'
main: 'dist/index.js'
3 changes: 2 additions & 1 deletion dist/index.js
Expand Up @@ -9706,6 +9706,7 @@ async function main() {
const workflow_id = core.getInput('workflow_id', { required: false });
const ignore_sha = core.getBooleanInput('ignore_sha', { required: false });
const all_but_latest = core.getBooleanInput('all_but_latest', { required: false });
const only_status = core.getInput('only_status', { required: false });
console.log(`Found token: ${token ? 'yes' : 'no'}`);
const workflow_ids = [];
const octokit = github.getOctokit(token);
Expand Down Expand Up @@ -9751,7 +9752,7 @@ async function main() {
const runningWorkflows = workflow_runs.filter(run => run.head_repository.id === trigger_repo_id &&
run.id !== current_run.id &&
(ignore_sha || run.head_sha !== headSha) &&
run.status !== 'completed' &&
(only_status ? run.status === only_status : run.status !== 'completed') &&
new Date(run.created_at) < cancelBefore);
if (all_but_latest && new Date(current_run.created_at) < cancelBefore) {
runningWorkflows.push(current_run);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -14,9 +14,9 @@
"@actions/github": "5.1.1"
},
"devDependencies": {
"@vercel/ncc": "0.36.0",
"@vercel/ncc": "0.36.1",
"husky": "8.0.3",
"prettier": "2.8.3",
"typescript": "4.9.4"
"typescript": "4.9.5"
}
}
3 changes: 2 additions & 1 deletion src/index.ts
Expand Up @@ -34,6 +34,7 @@ async function main() {
const workflow_id = core.getInput('workflow_id', { required: false });
const ignore_sha = core.getBooleanInput('ignore_sha', { required: false });
const all_but_latest = core.getBooleanInput('all_but_latest', { required: false });
const only_status = core.getInput('only_status', { required: false });
console.log(`Found token: ${token ? 'yes' : 'no'}`);
const workflow_ids: string[] = [];
const octokit = github.getOctokit(token);
Expand Down Expand Up @@ -90,7 +91,7 @@ async function main() {
run.head_repository.id === trigger_repo_id &&
run.id !== current_run.id &&
(ignore_sha || run.head_sha !== headSha) &&
run.status !== 'completed' &&
(only_status ? run.status === only_status : run.status !== 'completed') &&
new Date(run.created_at) < cancelBefore,
);
if (all_but_latest && new Date(current_run.created_at) < cancelBefore) {
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Expand Up @@ -149,10 +149,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.2.tgz#264b44c5a28dfa80198fc2f7b6d3c8a054b9491f"
integrity sha512-onlIwbaeqvZyniGPfdw/TEhKIh79pz66L1q06WUQqJLnAb6wbjvOtepLYTGHTqzdXgBYIE3ZdmqHDGsRsbBz7A==

"@vercel/ncc@0.36.0":
version "0.36.0"
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.36.0.tgz#1f262b86fc4f0770bbc0fc1d331d5aaa1bd47334"
integrity sha512-/ZTUJ/ZkRt694k7KJNimgmHjtQcRuVwsST2Z6XfYveQIuBbHR+EqkTc1jfgPkQmMyk/vtpxo3nVxe8CNuau86A==
"@vercel/ncc@0.36.1":
version "0.36.1"
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.36.1.tgz#d4c01fdbbe909d128d1bf11c7f8b5431654c5b95"
integrity sha512-S4cL7Taa9yb5qbv+6wLgiKVZ03Qfkc4jGRuiUQMQ8HGBD5pcNRnHeYM33zBvJE4/zJGjJJ8GScB+WmTsn9mORw==

before-after-hook@^2.2.0:
version "2.2.2"
Expand Down Expand Up @@ -208,10 +208,10 @@ tunnel@^0.0.6:
resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==

typescript@4.9.4:
version "4.9.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.4.tgz#a2a3d2756c079abda241d75f149df9d561091e78"
integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==
typescript@4.9.5:
version "4.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==

universal-user-agent@^6.0.0:
version "6.0.0"
Expand Down

0 comments on commit 42e641e

Please sign in to comment.