refactor: DB schema #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ master ] | |
tags: [ 'v*' ] | |
pull_request: | |
branches: [ master ] | |
env: | |
CARGO_TERM_COLOR: always | |
DATABASE_URL: sqlite:/tmp/bot.db | |
CONFIG_PATH: /tmp/config.yaml | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
check: | |
name: Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt, clippy | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Copy config | |
run: cp config.example.yaml /tmp/config.yaml | |
- name: Install sqlx-cli | |
run: cargo install sqlx-cli | |
- name: Create database | |
run: | | |
sqlx database create | |
sqlx migrate run | |
- name: Check formatting | |
run: cargo fmt --all -- --check | |
- name: Clippy | |
run: cargo clippy -- -D warnings | |
- name: Run tests | |
run: cargo test | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Copy config | |
run: cp config.example.yaml /tmp/config.yaml | |
- name: Install sqlx-cli | |
run: cargo install sqlx-cli | |
- name: Create database | |
run: | | |
sqlx database create | |
sqlx migrate run | |
- name: Build | |
run: cargo build --release | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: InvitationBot | |
path: target/release/InvitationBot | |
release: | |
name: Release | |
needs: [check, build] | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: InvitationBot | |
path: ./ | |
- name: Make binary executable | |
run: chmod +x InvitationBot | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
InvitationBot | |
generate_release_notes: true | |
docker: | |
name: Build and push Docker image | |
needs: [check] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@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@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=sha,format=long | |
type=ref,event=branch | |
type=ref,event=pr | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |