Skip to content

Commit

Permalink
trigger deploy only for affected apps
Browse files Browse the repository at this point in the history
  • Loading branch information
sitek94 committed Nov 25, 2023
1 parent 4c48612 commit 78b6e2d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
34 changes: 28 additions & 6 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion apps/remix/app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function Index() {
<hr />
<h2>Cats fetched from NestJS</h2>
<pre>{JSON.stringify(cats, null, 2)}</pre>
<p>Test</p>
<p>Test 2</p>
</div>
)
}

0 comments on commit 78b6e2d

Please sign in to comment.