-
Notifications
You must be signed in to change notification settings - Fork 1
76 lines (65 loc) · 2.09 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-Dwarnings"
jobs:
lint:
runs-on: ubuntu-latest
name: Lint
steps:
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
with:
shared-key: ci-build
# need to install tailwind for the build to run
- name: Install tailwind cli
run: wget -O tailwindcss https://github.com/tailwindlabs/tailwindcss/releases/download/$(wget -q -O - https://api.github.com/repos/tailwindlabs/tailwindcss/releases/latest | jq -r ".tag_name")/tailwindcss-linux-x64 && chmod u+x tailwindcss
- name: Run clippy
run: cargo clippy --verbose --no-deps
- name: Check formatting
run: cargo fmt --check --verbose
build-and-push-image:
name: Build and Push Docker Image
runs-on: ubuntu-latest
permissions:
packages: write
needs:
- lint
if: success() && github.ref_name == 'main' && github.event_name == 'push'
steps:
- uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Docker Metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: | # tag with commit hash and with 'latest'
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and Push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max