From 3afdb5c5dd1ab81b4540fc45199ec40c82439104 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Wed, 21 Jun 2023 19:14:50 -0700 Subject: [PATCH] chore(workflow): make workflow pass if files not changed --- .github/workflows/ci.yml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b59e7b0..83bd2ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,16 +4,8 @@ on: workflow_dispatch: push: branches: [ "main" ] - paths: - - 'Cargo.toml' - - 'Cargo.lock' - - 'crates/**' pull_request: branches: ["main" ] - paths: - - 'Cargo.toml' - - 'Cargo.lock' - - 'crates/**' concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} @@ -22,7 +14,20 @@ concurrency: cancel-in-progress: true jobs: + changes: + runs-on: ubuntu-latest + steps: + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v36 + with: + files: | + Cargo.toml + Cargo.lock + crates/** + tests: + if: jobs.changes.steps.changed-files.outputs.any_changed == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -38,6 +43,7 @@ jobs: run: cargo +nightly fmt --check release-binary: + if: jobs.changes.steps.changed-files.outputs.any_changed == 'true' needs: tests runs-on: ${{ matrix.os }} strategy: @@ -95,7 +101,7 @@ jobs: path: tabby_${{ matrix.target }} pre-release: - if: github.event_name != 'pull_request' + if: jobs.changes.steps.changed-files.outputs.any_changed == 'true' && github.event_name != 'pull_request' needs: release-binary runs-on: ubuntu-latest permissions: