From ce46ff8d002f8927a55e0945e83d42e7c08cb9fa Mon Sep 17 00:00:00 2001 From: siddhantCodes Date: Wed, 13 Nov 2024 11:26:33 +0530 Subject: [PATCH] Conditionally run gh actions to save resources - Tests and Formatting ignore `t/` and `fastn.com/` subfolders. It only runs when `.{rs,ftd,p1,html,js,css}` files are changed. - Optimize Images only runs on changes in the `fastn.com` subfolder - Fix env setting for `deploy-fastn-com.yml` --- .github/workflows/deploy-fastn-com.yml | 6 ++--- .github/workflows/optimize-images.yml | 8 +++---- .github/workflows/tests-and-formatting.yml | 28 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy-fastn-com.yml b/.github/workflows/deploy-fastn-com.yml index 03339c41e..31726d4c3 100644 --- a/.github/workflows/deploy-fastn-com.yml +++ b/.github/workflows/deploy-fastn-com.yml @@ -9,11 +9,11 @@ on: - '.github/workflows/deploy-fastn-com.yml' jobs: - env: - # https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions - FIFTHTRY_SITE_WRITE_TOKEN: ${{ secrets.FIFTHTRY_SITE_WRITE_TOKEN }} build: runs-on: ubuntu-latest + env: + # https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions + FIFTHTRY_SITE_WRITE_TOKEN: ${{ secrets.FIFTHTRY_SITE_WRITE_TOKEN }} steps: - uses: actions/checkout@v4 - run: source <(curl -fsSL https://fastn.com/install.sh) diff --git a/.github/workflows/optimize-images.yml b/.github/workflows/optimize-images.yml index 71658f660..f1546615b 100644 --- a/.github/workflows/optimize-images.yml +++ b/.github/workflows/optimize-images.yml @@ -5,10 +5,10 @@ on: branches: - main paths: - - '**.jpg' - - '**.jpeg' - - '**.png' - - '**.webp' + - 'fastn.com/**.jpg' + - 'fastn.com/**.jpeg' + - 'fastn.com/**.png' + - 'fastn.com/**.webp' jobs: build: name: calibreapp/image-actions diff --git a/.github/workflows/tests-and-formatting.yml b/.github/workflows/tests-and-formatting.yml index 20a21acec..011c91e52 100644 --- a/.github/workflows/tests-and-formatting.yml +++ b/.github/workflows/tests-and-formatting.yml @@ -4,8 +4,36 @@ on: workflow_dispatch: push: branches: [ main ] + paths: + # Order matters! + # See https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore + - '**.rs' + - '**.ftd' # ftd/html/js/css are fbt-tests items mostly + - '**.p1' + - '**.html' + - '**.js' + - '**.css' + - '!t/' # We use this for playground + - '!fastn.com/' + - '!v0.5/' # TODO: remove this when we're ready to release v0.5 + - '!.github/' + - '.github/workflows/tests-and-formatting.yml' pull_request: branches: [ main ] + paths: + # Order matters! + # See https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore + - '**.rs' + - '**.ftd' # ftd/html/js/css are fbt-tests items mostly + - '**.p1' + - '**.html' + - '**.js' + - '**.css' + - '!t/' # We use this for playground + - '!fastn.com/' + - '!v0.5/' # TODO: remove this when we're ready to release v0.5 + - '!.github/' + - '.github/workflows/tests-and-formatting.yml' jobs: tests-and-formatting: name: Rust/JS Checks/Formatting