Skip to content

Commit

Permalink
feat: add skip-run-names
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed Feb 24, 2021
1 parent 7154d88 commit 39be615
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v1.2.0

`2021.02.24`

- feat: add `skip-run-names`.

## v1.1.0

`2021.02.23`
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions-cool/check-pr-ci@v1.1.0
- uses: actions-cool/check-pr-ci@v1.2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
filter-label: 'check-ci'
Expand All @@ -46,6 +46,7 @@ jobs:
| filter-creator-authority | Filter PR by creator authority. | string | ✖ |
| filter-head-ref | Filter PR head ref branch. | string | ✖ |
| filter-support-fork | Filter PR come from. Default `true`. | boolean | ✖ |
| skip-run-names | Skip some run names. | string | ✖ |
| success-review | Whether to approve when success. | boolean | ✖ |
| success-review-body | Review body. | string | ✖ |
| success-merge | Whether to merge when success. | boolean | ✖ |
Expand All @@ -58,6 +59,7 @@ jobs:

- `merge-title`: `${number}` will be replaced with the current PR number
- `failure-review`: When use this, the `failure-review-body` is necessary
- `skip-run-names`: [GitHub Doc](https://docs.github.com/en/rest/reference/checks#list-check-runs-for-a-git-reference) `check_runs` `name`

## ⚡ Feedback

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ inputs:
description: Filter PR head ref branch.
filter-support-fork:
description: Filter PR come from.
# check
skip-run-names:
description: Skip some run names.
# resule
## success
success-review:
Expand Down
9 changes: 5 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6088,7 +6088,7 @@ run();
const core = __nccwpck_require__(186);
const { Octokit } = __nccwpck_require__(375);

const { checkPermission } = __nccwpck_require__(55);
const { dealStringToArr, checkPermission } = __nccwpck_require__(55);

const token = core.getInput('token');
const octokit = new Octokit({ auth: `token ${token}` });
Expand Down Expand Up @@ -6141,6 +6141,7 @@ async function checkAuthority(owner, repo, username, filterCreatorAuthority) {
}

async function getPRStatus(owner, repo, number) {
const skipRunNames = core.getInput('skip-run-names');
const { data: pr } = await octokit.pulls.get({
owner,
repo,
Expand All @@ -6163,16 +6164,16 @@ async function getPRStatus(owner, repo, number) {
let ifCICompleted = true;
let ifCIHasFailure = false;
runs.forEach(it => {
if (it.status !== 'completed') {
if (it.status == 'in_progress') {
ifCICompleted = false;
}
if (it.conclusion === 'failure') {
if (it.conclusion === 'failure' && !dealStringToArr(skipRunNames).includes(it.name)) {
ifCIHasFailure = true;
}
});

core.info(
`[getPRStatus] [number: ${number}] [commitState: ${commitState}] [ifCICompleted: ${ifCICompleted}] [ifCIHasFailure: ${ifCIHasFailure}]`,
`[getPRStatus] [number: ${number}/${runs.length}] [commit: ${commit}] [commitState: ${commitState}] [ifCICompleted: ${ifCICompleted}] [ifCIHasFailure: ${ifCIHasFailure}]`,
);

return {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "check-pr-ci",
"version": "1.1.0",
"version": "1.2.0",
"private": true,
"description": "Check the PR CI status and perform some operation after success or failure.",
"main": "src/main.js",
Expand Down
9 changes: 5 additions & 4 deletions src/octokit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const core = require('@actions/core');
const { Octokit } = require('@octokit/rest');

const { checkPermission } = require('actions-util');
const { dealStringToArr, checkPermission } = require('actions-util');

const token = core.getInput('token');
const octokit = new Octokit({ auth: `token ${token}` });
Expand Down Expand Up @@ -54,6 +54,7 @@ async function checkAuthority(owner, repo, username, filterCreatorAuthority) {
}

async function getPRStatus(owner, repo, number) {
const skipRunNames = core.getInput('skip-run-names');
const { data: pr } = await octokit.pulls.get({
owner,
repo,
Expand All @@ -76,16 +77,16 @@ async function getPRStatus(owner, repo, number) {
let ifCICompleted = true;
let ifCIHasFailure = false;
runs.forEach(it => {
if (it.status !== 'completed') {
if (it.status == 'in_progress') {
ifCICompleted = false;
}
if (it.conclusion === 'failure') {
if (it.conclusion === 'failure' && !dealStringToArr(skipRunNames).includes(it.name)) {
ifCIHasFailure = true;
}
});

core.info(
`[getPRStatus] [number: ${number}] [commitState: ${commitState}] [ifCICompleted: ${ifCICompleted}] [ifCIHasFailure: ${ifCIHasFailure}]`,
`[getPRStatus] [number: ${number}/${runs.length}] [commit: ${commit}] [commitState: ${commitState}] [ifCICompleted: ${ifCICompleted}] [ifCIHasFailure: ${ifCIHasFailure}]`,
);

return {
Expand Down

0 comments on commit 39be615

Please sign in to comment.