Skip to content

Commit

Permalink
ci(dispatch): skip label dispatching on PRs of dependabot (#3578)
Browse files Browse the repository at this point in the history
  • Loading branch information
clearloop authored Dec 13, 2023
1 parent 0694a22 commit 665d74b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
11 changes: 8 additions & 3 deletions .github/actions/label/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

const [owner, repo] = ["gear-tech", "gear"];
const { LABEL, REF, HEAD_SHA, TITLE, NUMBER } = process.env;
const { LABEL, REF, HEAD_SHA, TITLE, NUMBER, IS_FORK, REF_NAME } = process.env;
const linux =
LABEL === "A0-pleasereview" ||
LABEL === "A4-insubstantial" ||
Expand All @@ -20,8 +20,12 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

/**
* If skipping this action.
*
* @returns {Promise<[boolean, string]>} [skip, String(check_runs)]
**/
const skip = async ({ core, github }) => {
const skip = async ({ github }) => {
if (!IS_FORK && REF_NAME.startsWith("dependabot")) return [true, ""]

const {
data: { check_runs },
} = await github.rest.checks.listForRef({
Expand Down Expand Up @@ -142,7 +146,8 @@ const listJobs = async ({ github, core, run_id }) => {
* The main function.
**/
module.exports = async ({ github, core }) => {
const [skipAction, check_runs] = await skip({ core, github });
const [skipAction, check_runs] = await skip({ github });

if (skipAction) {
core.info("Build has already been processed, check runs: " + check_runs);
return;
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ jobs:
if: >-
needs.status.outputs.skip-ci != '1'
&& (
contains(github.event.pull_request.title, '[depbot]')
|| (
(
github.event.pull_request.head.repo.full_name == 'gear-tech/gear'
&& contains(github.event.pull_request.title, '[depbot]')
) || (
contains(github.event.pull_request.labels.*.name, 'A0-pleasereview')
|| contains(github.event.pull_request.labels.*.name, 'A4-insubstantial')
|| contains(github.event.pull_request.labels.*.name, 'A2-mergeoncegreen')
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ jobs:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
LABEL: ${{ github.event.label.name }}
REF: ${{ github.head_ref || github.ref_name }}
REF_NAME: ${{ github.ref_name }}
TITLE: ${{ github.event.pull_request.title }}
NUMBER: ${{ github.event.number }}
IS_FORK: ${{ github.event.pull_request.head.repo.full_name != 'gear-tech/gear' }}
with:
script: |
const script = require('./.github/actions/label/build.js');
Expand Down

0 comments on commit 665d74b

Please sign in to comment.