From 78b6e2d26d1635b480bd3a81d196db441ca5f3f7 Mon Sep 17 00:00:00 2001 From: Maciek Sitkowski Date: Sat, 25 Nov 2023 13:55:28 +0100 Subject: [PATCH] trigger deploy only for affected apps --- .github/workflows/validate.yml | 34 ++++++++++++++++++++++++++------ README.md | 12 +++++++++-- apps/remix/app/routes/_index.tsx | 2 +- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 3288f2b..b32b206 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -7,6 +7,28 @@ on: branches: [main] jobs: + changes: + name: Detect changes + runs-on: ubuntu-latest + outputs: + nestjs: ${{ steps.filter.outputs.nestjs }} + remix: ${{ steps.filter.outputs.remix }} + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Check for file changes + uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + nestjs: + - 'apps/nestjs/**' + - 'libs/types/**' + remix: + - 'apps/remix/**' + - 'apps/types/**' + validate: runs-on: ubuntu-latest @@ -39,10 +61,10 @@ jobs: deploy-nestjs: name: Deploy NestJS App + needs: [changes, validate] + if: needs.changes.outputs.nestjs == 'true' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest - # needs: [typecheck, lint, test, build] - needs: [validate] - if: ${{ github.ref == 'refs/heads/main' }} steps: - name: ⬇️ Checkout repo @@ -58,10 +80,10 @@ jobs: deploy-remix: name: Deploy Remix App + needs: [changes, validate] + if: needs.changes.outputs.remix == 'true' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest - # needs: [typecheck, lint, test, build] - needs: [validate] - if: ${{ github.ref == 'refs/heads/main' }} steps: - name: ⬇️ Checkout repo diff --git a/README.md b/README.md index 99b4fb3..d4ff442 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,16 @@ - [x] create CI workflow (lint + build only) - [x] add simple tests to CI workflow - [x] manually deploy to Fly.io -- [ ] create CI deployment workflow to Fly.io -- [ ] improve CI deployment workflow to trigger only for changed apps +- [x] create CI deployment workflow to Fly.io +- [x] improve CI deployment workflow to trigger only for changed apps - [ ] create shared ui lib - [ ] setup Storybook in shared ui lib - [x] set unified path aliases for all apps and shared libs (done for `apps/`, because `libs/` probably don't need them anyway) + +## References + +- https://pnpm.io/next/filtering +- https://github.com/remix-run/indie-stack/tree/main +- https://github.com/sveltejs/kit/tree/master +- https://github.com/nestjs/nest/tree/master/sample +- https://fly.io/docs/reference/configuration/#the-processes-section diff --git a/apps/remix/app/routes/_index.tsx b/apps/remix/app/routes/_index.tsx index b9c89c9..d898fdf 100644 --- a/apps/remix/app/routes/_index.tsx +++ b/apps/remix/app/routes/_index.tsx @@ -29,7 +29,7 @@ export default function Index() {

Cats fetched from NestJS

{JSON.stringify(cats, null, 2)}
-

Test

+

Test 2

) }