Skip to content

Commit 79bd9c5

Browse files
authored
Add conditional deploys (#26)
* Add conditional deploys. Update dev environment * Cast github expression check to string
1 parent 8344022 commit 79bd9c5

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

.github/workflows/build-n-publish.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,35 @@ on:
99
- main
1010

1111
jobs:
12+
setup:
13+
name: Deploy Setup
14+
runs-on: ubuntu-latest
15+
outputs:
16+
frontend-changed: ${{ steps.changes.outputs.frontend-changed }}
17+
data-changed: ${{ steps.changes.outputs.data-changed }}
18+
steps:
19+
- name: Checkout
20+
uses: actions/[email protected]
21+
22+
- name: Detect Changes
23+
id: changes
24+
run: |
25+
FRONTEND_DIFF=$(git diff --name-only origin/main -- frontend/* | wc -l | xargs)
26+
DATA_DIFF=$(git diff --name-only origin/main -- data/* | wc -l | xargs)
27+
28+
if [[ "$FRONTEND_DIFF" == "1" ]]; then
29+
echo "frontend-changed=true" >> $GITHUB_OUTPUT
30+
fi
31+
32+
if [[ "$DATA_DIFF" == "1" ]]; then
33+
echo "data-changed=true" >> $GITHUB_OUTPUT
34+
fi
35+
36+
1237
build-frontend:
1338
name: Build Frontend
39+
if: ${{ needs.setup.outputs.frontend-changed == 'true' }}
40+
needs: [setup]
1441
runs-on: ubuntu-latest
1542
steps:
1643
- name: Checkout
@@ -31,6 +58,8 @@ jobs:
3158

3259
deploy-frontend:
3360
name: Deploy Frontend
61+
if: ${{ needs.setup.outputs.frontend-changed == 'true' }}
62+
needs: [setup]
3463
runs-on: ubuntu-latest
3564
needs: build-frontend
3665
permissions:
@@ -47,6 +76,8 @@ jobs:
4776

4877
build-data:
4978
name: Build Data
79+
if: ${{ needs.setup.outputs.data-changed == 'true' }}
80+
needs: [setup]
5081
runs-on: ubuntu-latest
5182
steps:
5283
- name: Checkout

frontend/src/routes/posts/+page.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ import { getPosts } from '$lib/utils/loader.js';
33

44
export const load = ({fetch}) => {
55
return getPosts(fetch);
6-
76
}

shell.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ stdenv.mkDerivation {
44
name = "node";
55
buildInputs = [
66
nodejs
7+
actionlint
78
];
89
shellHook = ''
910
export PATH="$PWD/frontend/node_modules/.bin/:$PATH"

0 commit comments

Comments
 (0)