Skip to content

Commit 8c422d9

Browse files
CopilotPhantomDave
andcommitted
Refactor workflows: build images on PRs, deploy after successful builds
Co-authored-by: PhantomDave <34485699+PhantomDave@users.noreply.github.com>
1 parent d4b4fca commit 8c422d9

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

.github/workflows/build-backend-image.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ on:
99
- 'PhantomDave.BankTracking.Library/**'
1010
- 'Dockerfile'
1111
- '.github/workflows/build-backend-image.yml'
12+
pull_request:
13+
branches: [main]
14+
paths:
15+
- 'PhantomDave.BankTracking.Api/**'
16+
- 'PhantomDave.BankTracking.Data/**'
17+
- 'PhantomDave.BankTracking.Library/**'
18+
- 'Dockerfile'
19+
- '.github/workflows/build-backend-image.yml'
1220
workflow_dispatch:
1321

1422
env:
@@ -28,6 +36,7 @@ jobs:
2836
uses: actions/checkout@v5
2937

3038
- name: Log in to GitHub Container Registry
39+
if: github.event_name != 'pull_request'
3140
uses: docker/login-action@v3
3241
with:
3342
registry: ${{ env.REGISTRY }}
@@ -49,6 +58,6 @@ jobs:
4958
with:
5059
context: .
5160
file: ./Dockerfile
52-
push: true
61+
push: ${{ github.event_name != 'pull_request' }}
5362
tags: ${{ steps.meta.outputs.tags }}
5463
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/build-frontend-image.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
paths:
77
- 'frontend/**'
88
- '.github/workflows/build-frontend-image.yml'
9+
pull_request:
10+
branches: [main]
11+
paths:
12+
- 'frontend/**'
13+
- '.github/workflows/build-frontend-image.yml'
914
workflow_dispatch:
1015

1116
env:
@@ -78,6 +83,7 @@ jobs:
7883
path: frontend
7984

8085
- name: Log in to GitHub Container Registry
86+
if: github.event_name != 'pull_request'
8187
uses: docker/login-action@v3
8288
with:
8389
registry: ${{ env.REGISTRY }}
@@ -99,6 +105,6 @@ jobs:
99105
with:
100106
context: ./frontend
101107
file: ./frontend/Dockerfile
102-
push: true
108+
push: ${{ github.event_name != 'pull_request' }}
103109
tags: ${{ steps.meta.outputs.tags }}
104110
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/deploy-tailscale.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
name: Deploy via Tailscale
22

33
on:
4-
push:
4+
workflow_run:
5+
workflows: ["Build and Push Backend Image", "Build and Push Frontend Image"]
6+
types:
7+
- completed
58
branches: [main]
69
workflow_dispatch:
710

@@ -16,6 +19,7 @@ jobs:
1619
deploy:
1720
name: Deploy to Production
1821
runs-on: ubuntu-latest
22+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
1923
permissions:
2024
contents: read
2125
packages: read

0 commit comments

Comments
 (0)