-
Notifications
You must be signed in to change notification settings - Fork 89
142 lines (119 loc) · 4.02 KB
/
ci.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
name: CI
permissions:
packages: write
on:
push:
branches: ["main"]
pull_request:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
npm-test:
name: NPM Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Use Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
- run: npm ci
working-directory: web
- run: npm run build --if-present
working-directory: web
cargo-check:
name: Cargo check
runs-on: "ubuntu-latest"
steps:
- name: Check out the repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: "actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af" # v1
with:
profile: "minimal"
toolchain: "stable"
override: true
- uses: "actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505" # v1
with:
command: check
args: "--manifest-path=server/Cargo.toml"
cargo-test:
name: Cargo test
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: "actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af" # v1
with:
profile: "minimal"
toolchain: "stable"
override: true
- uses: "actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505" # v1
with:
command: test
args: "--manifest-path=server/Cargo.toml"
cargo-fmt:
name: Cargo format
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: "actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af" # v1
with:
profile: "minimal"
toolchain: "nightly"
override: true
- run: "rustup component add rustfmt"
- uses: "actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505" # v1
with:
command: fmt
args: "--all --manifest-path=server/Cargo.toml -- --check "
cargo-clippy:
name: Cargo clippy
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: "actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af" # v1
with:
profile: "minimal"
toolchain: "stable"
override: true
- run: "rustup component add clippy"
- uses: "actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505" # v1
with:
command: clippy
args: "--manifest-path=server/Cargo.toml"
# args: "--manifest-path=server/Cargo.toml -- -D warnings"
publish-docker:
name: Publish Docker image
runs-on: ubuntu-latest
needs:
- npm-test
- cargo-check
- cargo-test
- cargo-clippy
- cargo-fmt
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4 # v3
- name: Login to Docker Hub
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push
uses: docker/build-push-action@1ca370b3a9802c92e886402e0dd88098a2533b12 # v6
with:
context: .
target: runtime
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}