-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (62 loc) · 2.26 KB
/
Copy pathbuild.yml
File metadata and controls
78 lines (62 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: CI / Deploy
on:
# build & test on every PR or push
pull_request:
push:
branches:
- main # ⬅ only main triggers the deploy jobs
jobs:
# ------------------------------------------------------------
# 1) Build + test the .NET solution
# ------------------------------------------------------------
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: "6.0.x"
- name: Restore
run: dotnet restore InvoiceProcessor.sln
- name: Build
run: dotnet build InvoiceProcessor.sln --configuration Release --no-restore
- name: Test
run: dotnet test InvoiceProcessor.sln --no-build --verbosity normal
# ------------------------------------------------------------
# 2) Deploy BACKEND (only on pushes to main)
# ------------------------------------------------------------
deploy-backend:
needs: build-test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v3
- name: Install Fly CLI
uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy backend to Fly.io
working-directory: InvoiceProcessor.API
run: flyctl deploy -c InvoiceProcessor.API/fly.toml --remote-only -a invoice-backend-snowy-shape-2157
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
# ------------------------------------------------------------
# 3) Deploy FRONTEND (only on pushes to main)
# ------------------------------------------------------------
deploy-frontend:
needs: build-test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
environment: production
# All commands run inside the frontend/ sub-dir
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v3
- name: Install Fly CLI
uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy frontend to Fly.io
run: flyctl deploy --remote-only -a invoice-frontend
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}