-
-
Notifications
You must be signed in to change notification settings - Fork 10
147 lines (124 loc) · 3.99 KB
/
Copy pathci.yml
File metadata and controls
147 lines (124 loc) · 3.99 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: CI/CD
on:
push:
branches: [ "*" ]
pull_request:
branches: [ main ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
DO_REGISTRY: registry.digitalocean.com
DO_IMAGE_NAME: ${{ secrets.DIGITALOCEAN_REGISTRY_NAME }}/trendweight
jobs:
frontend-checks:
name: Frontend Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: apps/web/package-lock.json
- name: Install dependencies
working-directory: apps/web
run: npm ci
- name: TypeScript check
working-directory: apps/web
run: npm run typecheck
- name: Lint
working-directory: apps/web
run: npm run lint
backend-checks:
name: Backend Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Restore dependencies
working-directory: apps/api
run: dotnet restore
- name: Build
working-directory: apps/api
run: dotnet build --no-restore -c Release
- name: Test
working-directory: apps/api
run: dotnet test --no-build -c Release --verbosity normal
docker-build:
name: Docker Build
runs-on: ubuntu-latest
needs: [frontend-checks, backend-checks]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to DigitalOcean Container Registry
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ${{ env.DO_REGISTRY }}
username: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
password: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Extract metadata for GitHub Registry
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Extract metadata for DigitalOcean Registry
id: meta-do
uses: docker/metadata-action@v5
with:
images: ${{ env.DO_REGISTRY }}/${{ env.DO_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Get version
id: version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION="build-${{ github.run_number }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.ref == 'refs/heads/main' }}
tags: |
${{ steps.meta.outputs.tags }}
${{ steps.meta-do.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
VITE_SUPABASE_URL=${{ secrets.VITE_SUPABASE_URL }}
VITE_SUPABASE_ANON_KEY=${{ secrets.VITE_SUPABASE_ANON_KEY }}
VITE_APPLE_SERVICES_ID=${{ secrets.VITE_APPLE_SERVICES_ID }}
BUILD_TIME=${{ github.event.head_commit.timestamp }}
BUILD_COMMIT=${{ github.sha }}
BUILD_BRANCH=${{ github.ref_name }}
BUILD_VERSION=${{ steps.version.outputs.version }}
BUILD_REPO=${{ github.repository }}