-
Notifications
You must be signed in to change notification settings - Fork 64
170 lines (145 loc) · 5.03 KB
/
deploy.yml
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Deploy
on:
# allow manual dispatch
workflow_dispatch:
# run on pushes to master
push:
branches:
- master
- staging
paths-ignore:
- 'e2e/**'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
build:
runs-on: ubuntu-latest
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Get timestamp
id: timestamp
run: echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
cache: 'maven'
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 9
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Cache pnpm
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Cache Maven Deps
uses: actions/cache@v4
with:
path: $GITHUB_WORKSPACE/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build backend
working-directory: backend
run: mvn --batch-mode --errors --fail-at-end --show-version --no-transfer-progress install
- name: Install frontend deps
run: (cd frontend && pnpm install --frozen-lockfile)
- name: Set environment for branch
run: |
if [[ $GITHUB_REF == 'refs/heads/master' ]]; then
echo "BACKEND_DATA_HOST=https://hangar.papermc.io" >> $GITHUB_ENV
echo "SENTRY_ENV=production" >> $GITHUB_ENV
else
echo "BACKEND_DATA_HOST=https://hangar.papermc.dev" >> $GITHUB_ENV
echo "SENTRY_ENV=staging" >> $GITHUB_ENV
fi
- name: Lint frontend
#env:
# DEBUG: "hangar:*"
run: (cd frontend && pnpm lint:oxlint && pnpm lint:eslint)
- name: Sync forth and back with crowdin
uses: crowdin/github-action@v2
with:
upload_sources: true
download_translations: true
push_translations: false
create_pull_request: false
skip_untranslated_strings: true
config: 'crowdin.yml'
crowdin_branch_name: master
env:
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
- name: Build frontend
env:
# keep these in sync with compose!
BACKEND_HOST: "http://hangar_backend:8080"
PUBLIC_HOST: "https://hangar.papermc.dev"
# DEBUG: "hangar:*"
NODE_ENV: "production"
run: (cd frontend && pnpm build)
- name: Login to registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker (frontend)
id: frontend-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/frontend
tags: |
type=sha,enable=true,format=short,prefix=${{ env.BRANCH_NAME }}-,suffix=-${{ steps.timestamp.outputs.timestamp }}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push frontend Dockerfile
uses: docker/build-push-action@v6
with:
context: .
file: chart/dockerfiles/frontend/Dockerfile
tags: ${{ steps.frontend-meta.outputs.tags }}
labels: ${{ steps.frontend-meta.outputs.labels }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Extract metadata (tags, labels) for Docker (backend)
id: backend-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/backend
tags: |
type=sha,enable=true,format=short,prefix=${{ env.BRANCH_NAME }}-,suffix=-${{ steps.timestamp.outputs.timestamp }}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push backend Dockerfile
uses: docker/build-push-action@v6
with:
context: .
file: chart/dockerfiles/backend/Dockerfile
tags: ${{ steps.backend-meta.outputs.tags }}
labels: ${{ steps.backend-meta.outputs.labels }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max