Skip to content

Commit

Permalink
ci: Adding env reading
Browse files Browse the repository at this point in the history
  • Loading branch information
bush1D3v authored Jun 18, 2024
1 parent 2db98d9 commit 6bad204
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions .github/workflows/api.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
name: Navarro Blog API Build CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

env:
POSTGRES_URL: ${{ vars.BASE_URL }}
POSTGRES_USER: ${{ vars.DB_USER }}
POSTGRES_PASSWORD: ${{ vars.DB_PASSWORD }}
POSTGRES_PORT: ${{ vars.HTTP_PORT }}
POSTGRES_NAME: ${{ vars.DB_NAME }}
CARGO_TERM_COLOR: always
DB_HOST: ${{vars.DB_HOST}}
DB_PORT: ${{vars.DB_PORT}}
DB_NAME: ${{vars.DB_NAME}}
DB_USER: ${{vars.DB_USER}}
DB_PASSWORD: ${{vars.DB_PASSWORD}}
REDIS_HOST: ${{vars.REDIS_HOST}}
REDIS_PORT: ${{vars.REDIS_PORT}}
POOL_SIZE: ${{vars.POOL_SIZE}}

jobs:
build:
runs-on: ubuntu-22.04

services:
postgres:
image: postgres:16.3
env:
POSTGRES_URL: ${{ env.POSTGRES_URL }}
POSTGRES_USER: ${{ env.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
POSTGRES_PORT: ${{env.POSTGRES_PORT}}
POSTGRES_NAME: ${{env.POSTGRES_NAME}}
POSTGRES_DB: ${{ env.DB_NAME }}
POSTGRES_USER: ${{ env.DB_USER }}
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand Down Expand Up @@ -54,11 +56,14 @@ jobs:

- name: Run migrations
run: |
export DATABASE_URL=${{ vars.DB_USER }}://${{ vars.DB_USER }}:${{ vars.DB_PASSWORD }}@${{ vars.DB_HOST }}:${{ vars.DB_PORT }}/${{ vars.DB_NAME }}
export DATABASE_URL=postgres://${{ env.DB_USER }}:${{ env.DB_PASSWORD }}@localhost:${{ env.DB_PORT }}/${{ env.DB_NAME }}
diesel migration run
- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test -- --test-threads=1

- name: Run tests
run: cargo test -- --test-threads=1

0 comments on commit 6bad204

Please sign in to comment.