-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (130 loc) · 4.84 KB
/
main.yaml
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
name: Test and Build
on:
pull_request:
push:
branches: [main]
tags:
- "*"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
lint_ts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Cache typeshare-cli
id: cache-typeshare-cli
uses: actions/cache@v3
with:
path: ~/.cargo/bin/typeshare
key: ${{ runner.os }}-typeshare-cli-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-typeshare-cli-
- name: Install Rust Chain
uses: actions-rust-lang/setup-rust-toolchain@v1
if: steps.cache-typeshare-cli.outputs.cache-hit != 'true'
- name: Install type generator
if: steps.cache-typeshare-cli.outputs.cache-hit != 'true'
run: cargo install typeshare-cli --force
- name: Generate Bindings
run: typeshare ./backend --lang=typescript --output-file=frontend/bindings.ts
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm i
- name: lint
run: npx eslint .
- name: build
run: npm run build
format_ts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci
- name: format
run: npx prettier backend/ --check
format_rs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: Rustfmt Check
uses: actions-rust-lang/rustfmt@v1
build_and_push:
name: build_and_push
runs-on: ubuntu-latest
permissions:
packages: write
needs:
- lint_ts
- format_ts
- format_rs
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
env:
DOCKER_METADATA_PR_HEAD_SHA: true
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
tags: |
type=raw,value=edge,enable=${{ github.ref == 'refs/heads/main' }}
type=sha,format=short
type=semver,pattern={{raw}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64/v8