CI
This commit is contained in:
@@ -7,3 +7,7 @@ end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
188
.gitea/workflows/ci.yml
Normal file
188
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,188 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
schedule:
|
||||
- cron: "0 0 */5 * *"
|
||||
|
||||
jobs:
|
||||
typos:
|
||||
name: "Check typos"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Check typos
|
||||
uses: crate-ci/typos@master
|
||||
with:
|
||||
config: ./typos.toml
|
||||
|
||||
lychee:
|
||||
name: "Check links"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# Takes too long
|
||||
#- name: Restore lychee cache
|
||||
# uses: actions/cache@v3
|
||||
# with:
|
||||
# path: .lycheecache
|
||||
# key: lychee-cache
|
||||
# restore-keys: lychee-cache
|
||||
#key: cache-lychee-${{ github.sha }}
|
||||
#restore-keys: cache-lychee-
|
||||
- name: Check links
|
||||
id: lychee
|
||||
uses: lycheeverse/lychee-action@v1
|
||||
with:
|
||||
args: --config ./lychee.toml .
|
||||
fail: true
|
||||
|
||||
clippy:
|
||||
name: "Clippy"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: "Install Rust"
|
||||
run: |
|
||||
sudo apt update
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
sudo apt install --yes rustup
|
||||
rustup default 1.91.0
|
||||
|
||||
- name: Run clippy
|
||||
run: cargo clippy --all-targets --all-features
|
||||
|
||||
#check-version:
|
||||
# name: Check version
|
||||
# runs-on: ubuntu-latest
|
||||
# # Skip this job on push to main
|
||||
# # if: github.event_name != 'push' || github.ref != 'refs/heads/main'
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# with:
|
||||
# fetch-depth: 0
|
||||
#
|
||||
# - name: check version
|
||||
# run: |
|
||||
# # Get base branch (usually main)
|
||||
# BASE_REF="${{ github.base_ref }}"
|
||||
# if [ -z "$BASE_REF" ]; then
|
||||
# BASE_REF="main"
|
||||
# fi
|
||||
#
|
||||
# # Get current version
|
||||
# CURRENT_VERSION=$(grep -m 1 '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
|
||||
# echo "Current version: $CURRENT_VERSION"
|
||||
#
|
||||
# # Get version from base branch
|
||||
# git fetch origin $BASE_REF
|
||||
# BASE_VERSION=$(git show origin/$BASE_REF:Cargo.toml | grep -m 1 '^version = ' | sed 's/version = "\(.*\)"/\1/')
|
||||
# echo "Base version: $BASE_VERSION"
|
||||
#
|
||||
# # Check if version changed
|
||||
# if [ "$CURRENT_VERSION" = "$BASE_VERSION" ]; then
|
||||
# echo "::error::Version in Cargo.toml has not been changed."
|
||||
# exit 1
|
||||
# else
|
||||
# echo "Version has been updated from $BASE_VERSION to $CURRENT_VERSION"
|
||||
# fi
|
||||
|
||||
buildandtest:
|
||||
name: "Build and test"
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
# - check-version
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: "Install Rust"
|
||||
run: |
|
||||
sudo apt update
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
sudo apt install --yes rustup
|
||||
rustup default 1.91.0
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release --package webpage
|
||||
|
||||
- name: Test
|
||||
run: cargo test --release --workspace
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: webpage
|
||||
path: "target/release/webpage"
|
||||
retention-days: 10
|
||||
|
||||
|
||||
docker:
|
||||
name: "Build container"
|
||||
runs-on: ubuntu-latest
|
||||
# Only run on push to main or workflow_dispatch
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
|
||||
needs:
|
||||
- typos
|
||||
- clippy
|
||||
- buildandtest
|
||||
# - check-version
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ github.server_url }}
|
||||
username: mark
|
||||
password: ${{ secrets.API_TOKEN }}
|
||||
|
||||
- name: Extract metadata for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: git.betalupi.com/mark/betalupi-webpage
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=sha,prefix={{branch}}-
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
# Tags looks like ghcr.io/user/app:latest
|
||||
|
||||
# - name: Setup SSH
|
||||
# if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch' }}
|
||||
# run: |
|
||||
# mkdir -p ~/.ssh
|
||||
# echo "${{ secrets.DEPLOY_SSH_PRIV_KEY }}" > ~/.ssh/id_ed25519
|
||||
# chmod 600 ~/.ssh/id_ed25519
|
||||
# eval "$(ssh-agent -s)"
|
||||
# ssh-add ~/.ssh/id_ed25519
|
||||
# ssh-keyscan -p 5342 waypoint.betalupi.com >> ~/.ssh/known_hosts
|
||||
|
||||
# - name: Deploy
|
||||
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
# run: |
|
||||
# cat "site.tar.gz" | \
|
||||
# ssh mark@waypoint.betalupi.com -p 5342 \
|
||||
# "
|
||||
# cat > /home/mark/site.tar.gz; \
|
||||
# rm -dfr /var/www/site/public; \
|
||||
# tar -xf site.tar.gz --directory=/var/www/site;
|
||||
# "
|
||||
37
Dockerfile
Normal file
37
Dockerfile
Normal file
@@ -0,0 +1,37 @@
|
||||
FROM rust:1.91-bookworm AS base
|
||||
|
||||
#
|
||||
# MARK: Build
|
||||
#
|
||||
FROM base AS build
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
ca-certificates wget unzip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app/rust
|
||||
COPY . .
|
||||
RUN cargo build --release --workspace
|
||||
RUN cargo test --release --workspace
|
||||
|
||||
#
|
||||
# MARK: Release
|
||||
#
|
||||
FROM debian:bookworm@sha256:00cd074b40c4d99ff0c24540bdde0533ca3791edcdac0de36d6b9fb3260d89e2 AS deploy
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=build \
|
||||
/app/rust/target/release/webpage \
|
||||
/app/bin/
|
||||
|
||||
ENV PATH="/app/bin:$PATH"
|
||||
ENV RUST_BACKTRACE=full
|
||||
|
||||
ENTRYPOINT ["webpage", "--help"]
|
||||
9
docker-compose.yml
Normal file
9
docker-compose.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
services:
|
||||
betalupi:
|
||||
image: git.betalupi.com/mark/betalupi-webpage:latest
|
||||
container_name: betalupi
|
||||
restart: unless-stopped
|
||||
command: 'webpage serve 0.0.0.0:3000'
|
||||
|
||||
ports:
|
||||
- '8256:8256'
|
||||
Reference in New Issue
Block a user