From eb7ae7fb573199aac34fcc5d48f97889daa30f76 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Tue, 10 Dec 2024 16:37:46 +0100 Subject: [PATCH] enh(ci): skip workflow when no change on PR (#5334) --- .github/workflows/as400.yml | 13 ++ .github/workflows/connector-vmware.yml | 14 +- .../docker-builder-packaging-plugins.yml | 18 ++- .../docker-builder-testing-plugins.yml | 18 ++- .../workflows/docker-builder-unit-tests.yml | 18 ++- .github/workflows/get-environment.yml | 122 ++++++++++++++++++ .github/workflows/nrpe.yml | 13 ++ .github/workflows/perl-cpan-libraries.yml | 38 +++++- .github/workflows/perl-crypt-argon2.yml | 14 +- .github/workflows/perl-filesys-smbclient.yml | 23 +++- .github/workflows/perl-json-path.yml | 14 +- .github/workflows/perl-keepass-reader.yml | 12 ++ .github/workflows/perl-libssh-session.yml | 14 +- .github/workflows/perl-net-curl.yml | 14 +- .github/workflows/perl-openwsman.yml | 14 +- .github/workflows/perl-vmware-vsphere.yml | 17 ++- .github/workflows/plink.yml | 19 ++- .github/workflows/plugins-selinux.yml | 13 ++ .github/workflows/plugins.yml | 14 ++ .../workflows/set-pull-request-skip-label.yml | 26 ++++ 20 files changed, 427 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/as400.yml b/.github/workflows/as400.yml index 8a473ee7d1..098b834d42 100644 --- a/.github/workflows/as400.yml +++ b/.github/workflows/as400.yml @@ -24,6 +24,9 @@ jobs: package: needs: [get-environment] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-22.04 strategy: fail-fast: false @@ -107,6 +110,7 @@ jobs: deliver-packages: needs: [get-environment, package] if: | + needs.get-environment.outputs.skip_workflow == 'false' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -141,3 +145,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/connector-vmware.yml b/.github/workflows/connector-vmware.yml index 2e6738598f..3e42dc8c69 100644 --- a/.github/workflows/connector-vmware.yml +++ b/.github/workflows/connector-vmware.yml @@ -26,7 +26,9 @@ jobs: package: needs: [get-environment] - if: ${{ needs.get-environment.outputs.stability != 'stable' }} + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-22.04 strategy: matrix: @@ -84,6 +86,7 @@ jobs: deliver-packages: needs: [get-environment, package] if: | + needs.get-environment.outputs.skip_workflow == 'false' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -118,3 +121,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/docker-builder-packaging-plugins.yml b/.github/workflows/docker-builder-packaging-plugins.yml index f220d1baf8..4ad9c1b1f1 100644 --- a/.github/workflows/docker-builder-packaging-plugins.yml +++ b/.github/workflows/docker-builder-packaging-plugins.yml @@ -18,7 +18,14 @@ on: - ".github/docker/packaging/*" jobs: - create-and-push-docker: + get-environment: + uses: ./.github/workflows/get-environment.yml + + dockerize: + needs: [get-environment] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' strategy: fail-fast: false matrix: @@ -87,3 +94,12 @@ jobs: pull: true push: true tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest + + set-skip-label: + needs: [get-environment, dockerize] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/docker-builder-testing-plugins.yml b/.github/workflows/docker-builder-testing-plugins.yml index 07ea371bb9..2872c99db4 100644 --- a/.github/workflows/docker-builder-testing-plugins.yml +++ b/.github/workflows/docker-builder-testing-plugins.yml @@ -18,7 +18,14 @@ on: - ".github/docker/testing/*" jobs: - create-and-push-docker: + get-environment: + uses: ./.github/workflows/get-environment.yml + + dockerize: + needs: [get-environment] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' strategy: fail-fast: false matrix: @@ -72,3 +79,12 @@ jobs: pull: true push: true tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/testing-plugins-${{ matrix.image }}:latest + + set-skip-label: + needs: [get-environment, dockerize] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/docker-builder-unit-tests.yml b/.github/workflows/docker-builder-unit-tests.yml index 53860637d7..184f2b726d 100644 --- a/.github/workflows/docker-builder-unit-tests.yml +++ b/.github/workflows/docker-builder-unit-tests.yml @@ -18,7 +18,14 @@ on: - ".github/docker/unit-tests/*" jobs: - create-and-push-docker: + get-environment: + uses: ./.github/workflows/get-environment.yml + + dockerize: + needs: [get-environment] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' strategy: fail-fast: false matrix: @@ -72,3 +79,12 @@ jobs: pull: true push: true tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/unit-tests-${{ matrix.image }}:latest + + set-skip-label: + needs: [get-environment, dockerize] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/get-environment.yml b/.github/workflows/get-environment.yml index d1fc8d2bfe..14c1eba61d 100644 --- a/.github/workflows/get-environment.yml +++ b/.github/workflows/get-environment.yml @@ -23,6 +23,9 @@ on: is_targeting_feature_branch: description: "if it is a PR, check if targeting a feature branch" value: ${{ jobs.get-environment.outputs.is_targeting_feature_branch }} + skip_workflow: + description: "if the current workflow should be skipped" + value: ${{ jobs.get-environment.outputs.skip_workflow }} jobs: get-environment: @@ -34,10 +37,128 @@ jobs: target_stability: ${{ steps.get_stability.outputs.target_stability }} release_type: ${{ steps.get_release_type.outputs.release_type }} is_targeting_feature_branch: ${{ steps.get_stability.outputs.is_targeting_feature_branch }} + skip_workflow: ${{ steps.skip_workflow.outputs.result }} steps: + - name: Check if PR has skip label + id: has_skip_label + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + let hasSkipLabel = false; + if (${{ contains(fromJSON('["pull_request", "pull_request_target"]') , github.event_name) }} === true) { + try { + const labels = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + labels.data.forEach(({ name }) => { + if (name === '${{ format('skip-workflow-{0}', github.workflow) }}') { + hasSkipLabel = true; + } + }); + } catch (e) { + core.warning(`failed to list labels: ${e}`); + } + } + return hasSkipLabel; + - name: Checkout sources (current branch) uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + with: + fetch-depth: ${{ steps.has_skip_label.outputs.result == 'true' && 100 || 1 }} + + - if: ${{ steps.has_skip_label.outputs.result == 'true' }} + name: Get workflow triggered paths + id: get_workflow_triggered_paths + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + const fs = require('fs'); + + let paths = []; + + const workflowFilePath = '${{ github.workflow_ref }}'.replace('${{ github.repository }}/', '').split('@').shift(); + + if (fs.existsSync(workflowFilePath)) { + const workflowFileContent = fs.readFileSync(workflowFilePath, 'utf8'); + const workflowFileContentLines = workflowFileContent.split('\n'); + + let hasReadOn = false; + let hasReadPullRequest = false; + let hasReadPaths = false; + for (const line of workflowFileContentLines) { + if (line.match(/^on:\s*$/)) { + hasReadOn = true; + continue; + } + if (line.match(/^\s{2}pull_request(_target)?:\s*$/)) { + hasReadPullRequest = true; + continue; + } + if (line.match(/^\s{4}paths:\s*$/)) { + hasReadPaths = true; + continue; + } + + if (hasReadOn && hasReadPullRequest && hasReadPaths) { + const matches = line.match(/^\s{6}-\s['"](.+)['"]\s*$/); + if (matches) { + paths.push(matches[1].trim()); + } else { + break; + } + } + } + } + + if (paths.length === 0) { + paths = ['**']; + } + + console.log(paths); + + return paths; + + - if: ${{ steps.has_skip_label.outputs.result == 'true' }} + name: Get push changes + id: get_push_changes + uses: tj-actions/changed-files@bab30c2299617f6615ec02a68b9a40d10bd21366 # v45.0.5 + with: + since_last_remote_commit: true + json: true + escape_json: false + files: ${{ join(fromJSON(steps.get_workflow_triggered_paths.outputs.result), ';') }} + files_separator: ';' + + - name: Check if current workflow should be skipped + id: skip_workflow + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + if (${{ steps.has_skip_label.outputs.result }} === false) { + return false; + } + + const label = '${{ format('skip-workflow-{0}', github.workflow) }}'; + if ('${{ steps.get_push_changes.outputs.any_changed }}' === 'true') { + try { + await github.rest.issues.removeLabel({ + name: label, + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + core.notice(`label ${label} removed because changes were detected on last push.`); + } catch (e) { + core.warning(`failed to remove label ${label}: ${e}`); + } + + return false; + } + + return true; - if: ${{ github.event_name == 'pull_request' }} name: Get nested pull request path @@ -155,6 +276,7 @@ jobs: ['release_type', '${{ steps.get_release_type.outputs.release_type || 'not defined because this is not a release' }}'], ['is_targeting_feature_branch', '${{ steps.get_stability.outputs.is_targeting_feature_branch }}'], ['target_stability', '${{ steps.get_stability.outputs.target_stability || 'not defined because current run is not triggered by pull request event' }}'], + ['skip_workflow', '${{ steps.skip_workflow.outputs.result }}'] ]; core.summary .addHeading(`${context.workflow} environment outputs`) diff --git a/.github/workflows/nrpe.yml b/.github/workflows/nrpe.yml index 88e06dacac..7d335f7138 100644 --- a/.github/workflows/nrpe.yml +++ b/.github/workflows/nrpe.yml @@ -24,6 +24,9 @@ jobs: package: needs: [get-environment] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-24.04 strategy: fail-fast: false @@ -117,6 +120,7 @@ jobs: deliver-packages: needs: [get-environment, package] if: | + needs.get-environment.outputs.skip_workflow == 'false' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -151,3 +155,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/perl-cpan-libraries.yml b/.github/workflows/perl-cpan-libraries.yml index b9bc4ed112..988cc04cf6 100644 --- a/.github/workflows/perl-cpan-libraries.yml +++ b/.github/workflows/perl-cpan-libraries.yml @@ -24,7 +24,9 @@ jobs: package-rpm: needs: [get-environment] - if: ${{ needs.get-environment.outputs.stability != 'stable' }} + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-24.04 strategy: @@ -238,7 +240,10 @@ jobs: retention-days: 1 merge-package-rpm-artifacts: - needs: [package-rpm] + needs: [get-environment, package-rpm] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-24.04 strategy: matrix: @@ -260,7 +265,10 @@ jobs: failOnError: false sign-rpm: - needs: [merge-package-rpm-artifacts] + needs: [get-environment, merge-package-rpm-artifacts] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-24.04 strategy: @@ -298,7 +306,9 @@ jobs: package-deb: needs: [get-environment] - if: ${{ needs.get-environment.outputs.stability != 'stable' }} + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ${{ matrix.runner_name }} strategy: @@ -470,7 +480,10 @@ jobs: retention-days: 1 merge-package-deb-artifacts: - needs: [package-deb] + needs: [get-environment, package-deb] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-24.04 strategy: matrix: @@ -492,7 +505,10 @@ jobs: failOnError: false download-and-cache-deb: - needs: [merge-package-deb-artifacts] + needs: [get-environment, merge-package-deb-artifacts] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-24.04 strategy: matrix: @@ -511,6 +527,7 @@ jobs: deliver-packages: needs: [get-environment, sign-rpm, download-and-cache-deb] if: | + needs.get-environment.outputs.skip_workflow == 'false' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -545,3 +562,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/perl-crypt-argon2.yml b/.github/workflows/perl-crypt-argon2.yml index 78b6b23abf..7680b17e4e 100644 --- a/.github/workflows/perl-crypt-argon2.yml +++ b/.github/workflows/perl-crypt-argon2.yml @@ -26,7 +26,9 @@ jobs: package: needs: [get-environment] - if: ${{ needs.get-environment.outputs.stability != 'stable' }} + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' strategy: fail-fast: false @@ -144,6 +146,7 @@ jobs: deliver-packages: needs: [get-environment, package] if: | + needs.get-environment.outputs.skip_workflow == 'false' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -187,3 +190,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/perl-filesys-smbclient.yml b/.github/workflows/perl-filesys-smbclient.yml index 626b663f2b..4b1d28e2d2 100644 --- a/.github/workflows/perl-filesys-smbclient.yml +++ b/.github/workflows/perl-filesys-smbclient.yml @@ -24,7 +24,9 @@ jobs: package-rpm: needs: [get-environment] - if: ${{ needs.get-environment.outputs.stability != 'stable' }} + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-22.04 strategy: @@ -67,7 +69,10 @@ jobs: key: unsigned-${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }} sign-rpm: - needs: [package-rpm] + needs: [get-environment, package-rpm] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-22.04 strategy: matrix: @@ -110,7 +115,9 @@ jobs: package-deb: needs: [get-environment] - if: ${{ needs.get-environment.outputs.stability != 'stable' }} + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-22.04 strategy: @@ -156,6 +163,7 @@ jobs: deliver-packages: needs: [get-environment, sign-rpm, package-deb] if: | + needs.get-environment.outputs.skip_workflow == 'false' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -190,3 +198,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/perl-json-path.yml b/.github/workflows/perl-json-path.yml index a53855a48c..379b50f16b 100644 --- a/.github/workflows/perl-json-path.yml +++ b/.github/workflows/perl-json-path.yml @@ -26,7 +26,9 @@ jobs: package: needs: [get-environment] - if: ${{ needs.get-environment.outputs.stability != 'stable' }} + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' strategy: fail-fast: false @@ -129,6 +131,7 @@ jobs: deliver-packages: needs: [get-environment, package] if: | + needs.get-environment.outputs.skip_workflow == 'false' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -163,3 +166,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/perl-keepass-reader.yml b/.github/workflows/perl-keepass-reader.yml index 9a5016b795..b417f6be44 100644 --- a/.github/workflows/perl-keepass-reader.yml +++ b/.github/workflows/perl-keepass-reader.yml @@ -27,6 +27,9 @@ jobs: package: needs: [get-environment] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' strategy: fail-fast: false @@ -154,3 +157,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/perl-libssh-session.yml b/.github/workflows/perl-libssh-session.yml index d56ac394df..53df82f574 100644 --- a/.github/workflows/perl-libssh-session.yml +++ b/.github/workflows/perl-libssh-session.yml @@ -24,7 +24,9 @@ jobs: package: needs: [get-environment] - if: ${{ needs.get-environment.outputs.stability != 'stable' }} + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' strategy: fail-fast: false @@ -142,6 +144,7 @@ jobs: deliver-packages: needs: [get-environment, package] if: | + needs.get-environment.outputs.skip_workflow == 'false' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -185,3 +188,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/perl-net-curl.yml b/.github/workflows/perl-net-curl.yml index 64b85d5e34..38b38938aa 100644 --- a/.github/workflows/perl-net-curl.yml +++ b/.github/workflows/perl-net-curl.yml @@ -24,7 +24,9 @@ jobs: package: needs: [get-environment] - if: ${{ needs.get-environment.outputs.stability != 'stable' }} + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' strategy: fail-fast: false @@ -142,6 +144,7 @@ jobs: deliver-packages: needs: [get-environment, package] if: | + needs.get-environment.outputs.skip_workflow == 'false' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -185,3 +188,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/perl-openwsman.yml b/.github/workflows/perl-openwsman.yml index c578ce7681..12474ae022 100644 --- a/.github/workflows/perl-openwsman.yml +++ b/.github/workflows/perl-openwsman.yml @@ -22,7 +22,9 @@ jobs: package: needs: [get-environment] - if: ${{ needs.get-environment.outputs.stability != 'stable' }} + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' strategy: fail-fast: false @@ -214,6 +216,7 @@ jobs: deliver-packages: needs: [get-environment, package] if: | + needs.get-environment.outputs.skip_workflow == 'false' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -257,3 +260,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/perl-vmware-vsphere.yml b/.github/workflows/perl-vmware-vsphere.yml index 65f83d0e5b..7be8efc489 100644 --- a/.github/workflows/perl-vmware-vsphere.yml +++ b/.github/workflows/perl-vmware-vsphere.yml @@ -24,7 +24,9 @@ jobs: get-sources: needs: [get-environment] - if: ${{ needs.get-environment.outputs.stability != 'stable' }} + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-22.04 steps: - name: Download vsphere cli sources @@ -48,6 +50,9 @@ jobs: package: needs: [get-environment, get-sources] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' strategy: matrix: @@ -148,6 +153,7 @@ jobs: deliver-packages: needs: [get-environment, package] if: | + needs.get-environment.outputs.skip_workflow == 'false' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -191,3 +197,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/plink.yml b/.github/workflows/plink.yml index 80ad2d9d23..31a4435e1c 100644 --- a/.github/workflows/plink.yml +++ b/.github/workflows/plink.yml @@ -24,7 +24,9 @@ jobs: package-rpm: needs: [get-environment] - if: ${{ needs.get-environment.outputs.stability != 'stable' }} + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-22.04 strategy: matrix: @@ -61,7 +63,10 @@ jobs: key: unsigned-${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }} sign-rpm: - needs: [package-rpm] + needs: [get-environment, package-rpm] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-22.04 strategy: matrix: @@ -111,6 +116,7 @@ jobs: deliver-packages: needs: [get-environment, sign-rpm] if: | + needs.get-environment.outputs.skip_workflow == 'false' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -139,3 +145,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/plugins-selinux.yml b/.github/workflows/plugins-selinux.yml index 355958558c..c8a5c906b4 100644 --- a/.github/workflows/plugins-selinux.yml +++ b/.github/workflows/plugins-selinux.yml @@ -24,6 +24,9 @@ jobs: package: needs: [get-environment] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + needs.get-environment.outputs.stability != 'stable' runs-on: ubuntu-22.04 strategy: matrix: @@ -72,6 +75,7 @@ jobs: deliver-packages: needs: [get-environment, package] if: | + needs.get-environment.outputs.skip_workflow == 'false' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -100,3 +104,12 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index be181d7a47..14bb8b2e66 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -90,6 +90,7 @@ jobs: unit-tests: needs: [get-environment, get-plugins] if: | + needs.get-environment.outputs.skip_workflow == 'false' && needs.get-environment.outputs.stability != 'stable' && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -145,6 +146,7 @@ jobs: fatpacker: needs: [get-environment, get-plugins, unit-tests] if: | + needs.get-environment.outputs.skip_workflow == 'false' && needs.get-plugins.outputs.plugins != '' && ! cancelled() && ! contains(needs.*.result, 'failure') && @@ -175,6 +177,7 @@ jobs: runs-on: ubuntu-24.04 needs: [get-environment, get-plugins, fatpacker] if: | + needs.get-environment.outputs.skip_workflow == 'false' && needs.get-plugins.outputs.plugins != '' && needs.get-environment.outputs.stability != 'stable' && ! cancelled() && @@ -299,6 +302,7 @@ jobs: test-plugins: needs: [get-environment, get-plugins, package] if: | + needs.get-environment.outputs.skip_workflow == 'false' && needs.get-plugins.outputs.plugins != '' && needs.get-environment.outputs.stability != 'stable' && ! cancelled() && @@ -358,6 +362,7 @@ jobs: deliver-packages: needs: [get-environment, get-plugins, test-plugins] if: | + needs.get-environment.outputs.skip_workflow == 'false' && needs.get-plugins.outputs.plugins != '' && (contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || (needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) && ! cancelled() && @@ -448,3 +453,12 @@ jobs: echo "::warning::Release tag $RELEASE already exists" fi shell: bash + + set-skip-label: + needs: [get-environment, deliver-packages] + if: | + needs.get-environment.outputs.skip_workflow == 'false' && + ! cancelled() && + ! contains(needs.*.result, 'failure') && + ! contains(needs.*.result, 'cancelled') + uses: ./.github/workflows/set-pull-request-skip-label.yml diff --git a/.github/workflows/set-pull-request-skip-label.yml b/.github/workflows/set-pull-request-skip-label.yml new file mode 100644 index 0000000000..ffab0b955e --- /dev/null +++ b/.github/workflows/set-pull-request-skip-label.yml @@ -0,0 +1,26 @@ +name: set-pull-request-skip-label + +on: + workflow_call: + +jobs: + set-pull-request-skip-label: + if: ${{ success() && contains(fromJSON('["pull_request", "pull_request_target"]') , github.event_name) }} + runs-on: ubuntu-24.04 + + steps: + - name: Set PR skip label + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + const label = '${{ format('skip-workflow-{0}', github.workflow) }}'; + try { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: [label] + }); + } catch (e) { + core.warning(`failed to add label ${label}: ${e}`); + }