Skip to content

Commit e25b978

Browse files
committed
Base release action on GHA
1 parent 89b1ea2 commit e25b978

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

.dockerignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
tags: ["v[0-9]+.[0-9]+.[0-9]+*"]
66
workflow_dispatch:
77

8+
env:
9+
DATABASE_URL: "sqlite://rebot.sqlite3?mode=rwc"
10+
CARGO_TERM_COLOR: always
11+
812
jobs:
913
release:
1014
runs-on: ubuntu-latest
@@ -13,6 +17,33 @@ jobs:
1317
packages: write
1418

1519
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/cache@v4
23+
with:
24+
path: |
25+
~/.cargo/bin/
26+
~/.cargo/registry/index/
27+
~/.cargo/registry/cache/
28+
~/.cargo/git/db/
29+
target/
30+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
31+
32+
- name: Install sqlx-cli
33+
run: |
34+
SQLX_CLI_VERSION="$(sed -rn 's/^sqlx = \{ version = "([0-9.]+)".*$/\1/p' Cargo.toml)"
35+
echo "Required sqlx-cli version: $SQLX_CLI_VERSION"
36+
cargo install sqlx-cli --force --version "$SQLX_CLI_VERSION" --no-default-features --features sqlite
37+
38+
- name: Set Up the Database
39+
run: sqlx database setup
40+
41+
- name: Build
42+
run: cargo build --profile release
43+
44+
- name: Test
45+
run: cargo test --profile release
46+
1647
- name: Log in to the Container registry
1748
uses: docker/login-action@v3
1849
with:
@@ -23,10 +54,9 @@ jobs:
2354
- name: Set up Docker Buildx
2455
uses: docker/setup-buildx-action@v3
2556

26-
- name: Build and push
57+
- name: Build and Push
2758
uses: docker/build-push-action@v6
2859
with:
60+
context: .
2961
push: true
3062
tags: "${{ vars.IMAGE_REGISTRY }}/${{ vars.IMAGE_NAME }}:latest,${{ vars.IMAGE_REGISTRY }}/${{ vars.IMAGE_NAME }}:${{ github.ref_name }}"
31-
cache-from: type=gha
32-
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1-
FROM lukemathwalker/cargo-chef:0.1.72-rust-1.88.0-bookworm AS chef
2-
WORKDIR /app
3-
4-
FROM chef AS planner
5-
COPY . .
6-
RUN cargo chef prepare --recipe-path recipe.json
7-
8-
FROM chef AS builder
9-
COPY --from=planner /app/recipe.json recipe.json
10-
11-
RUN cargo chef cook --release --recipe-path recipe.json
12-
13-
COPY . .
14-
15-
RUN DATABASE_URL="sqlite://rebot.sqlite3?mode=rwc" cargo build --release
16-
171
FROM gcr.io/distroless/cc-debian12
182

19-
COPY --from=builder /app/target/release/rating-exchange-bot /
3+
ARG PROFILE=release
4+
5+
COPY ./target/${PROFILE}/rating-exchange-bot /rating-exchange-bot
206

217
CMD ["./rating-exchange-bot"]

0 commit comments

Comments
 (0)