ci: trying make the pipeline work #128
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: Unit Tests & Build | |
# Trigger the workflow when changes are pushed to the main branch | |
on: | |
push: | |
branches: | |
- main | |
- features/* | |
- '!wip/*' | |
workflow_dispatch: | |
inputs: | |
deploy: | |
description: 'Triggers the deploy workflow' | |
type: boolean | |
required: true | |
default: false | |
env: | |
BASE_PATH: ${{ vars.BASE_PATH }} | |
ENVIRONMENT: 'remote' | |
RECAPTCHA_SECRET: ${{ secrets.RECAPTCHA_SECRET }} | |
JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
DROPLET_IP: ${{ vars.DROPLET_IP }} | |
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
SQLX_OFFLINE: true | |
jobs: | |
deploy: | |
name: Deploy | |
uses: ./.github/workflows/deploy.yml | |
needs: build | |
secrets: inherit | |
build: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:15.2-alpine | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
POSTGRES_DB: postgres | |
ports: | |
- 5432:5432 | |
redis: | |
image: redis:7.0-alpine | |
ports: | |
- 6379:6379 | |
steps: | |
# Checkout code from the repository | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Cache dependencies to speed up build times | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
app-service/.cargo | |
app-service/target/ | |
auth-service/.cargo | |
auth-service/target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: ${{ runner.os }}-cargo- | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
- name: Build and test app-service code | |
working-directory: ./app-service | |
run: | | |
cargo build --verbose | |
# cargo test --verbose | |
- name: Build and test auth-service code | |
working-directory: ./auth-service | |
run: | | |
export JWT_SECRET=secret | |
export SQLX_OFFLINE=${{ env.SQLX_OFFLINE }} | |
export DATABASE_URL=postgres://postgres:${{ secrets.POSTGRES_PASSWORD }}@localhost:5432 | |
cargo build --verbose | |
# cargo test --verbose | |
# Set up Docker Buildx for multi-platform builds | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker images | |
uses: docker/bake-action@v4 | |
with: | |
push: true | |
# set: | | |
# *.cache-from=type=gha | |
# *.cache-to=type=gha,mode=max |