57 lines
1.6 KiB
YAML
57 lines
1.6 KiB
YAML
name: Build Project
|
|
|
|
on: [push]
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: rust:bullseye
|
|
|
|
# Service containers to run with `container-job`
|
|
services:
|
|
# Label used to access the service container
|
|
db:
|
|
# Docker Hub image
|
|
image: postgres:latest
|
|
# Provide the password for postgres
|
|
env:
|
|
POSTGRES_USER: dev
|
|
POSTGRES_PASSWORD: dev
|
|
POSTGRES_DB: iot
|
|
# Set health checks to wait until postgres has started
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
|
|
steps:
|
|
- name: Install necessary dependencies
|
|
run: apt update && apt install nodejs pkg-config -y
|
|
- name: Install docker
|
|
run: curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v2
|
|
- name: Run migrations
|
|
run: cargo install sqlx-cli && sqlx migrate run
|
|
- name: Build server binary
|
|
run: cargo build --release
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
- name: Log in to Docker Registry
|
|
uses: docker/login-action@v1
|
|
with:
|
|
registry: gitea.maiertobi.de # Replace with your Docker registry URL
|
|
username: tobimai
|
|
password: ${{ secrets.docker_registry_key }}
|
|
- name: Build and Push Docker Image
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: gitea.maiertobi.de/tobimai/iot # Replace with your Docker image's details
|
|
|
|
|