chore(workflow): make workflow pass if files not changed

improve-workflow
Meng Zhang 2023-06-21 19:14:50 -07:00
parent 41c747e295
commit 3afdb5c5dd
1 changed files with 15 additions and 9 deletions

View File

@ -4,16 +4,8 @@ on:
workflow_dispatch: workflow_dispatch:
push: push:
branches: [ "main" ] branches: [ "main" ]
paths:
- 'Cargo.toml'
- 'Cargo.lock'
- 'crates/**'
pull_request: pull_request:
branches: ["main" ] branches: ["main" ]
paths:
- 'Cargo.toml'
- 'Cargo.lock'
- 'crates/**'
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
@ -22,7 +14,20 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
jobs: 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: tests:
if: jobs.changes.steps.changed-files.outputs.any_changed == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -38,6 +43,7 @@ jobs:
run: cargo +nightly fmt --check run: cargo +nightly fmt --check
release-binary: release-binary:
if: jobs.changes.steps.changed-files.outputs.any_changed == 'true'
needs: tests needs: tests
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
@ -95,7 +101,7 @@ jobs:
path: tabby_${{ matrix.target }} path: tabby_${{ matrix.target }}
pre-release: 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 needs: release-binary
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions: