Skip to content

Commit

Permalink
cicd: test sqlite/upload sqlite db to gh release
Browse files Browse the repository at this point in the history
  • Loading branch information
Naramsim committed Feb 14, 2025
1 parent bed1306 commit 9aa187d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
name: Database

on:
push:
pull_request:

jobs:
sqlite:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Start pokeapi
run: |
make install
make migrate
make build-db
nohup make serve &
sleep 3
- name: Dump DB
run: stat db.sqlite3
- name: Test data
run: curl -Ss http://localhost:8000/api/v2/pokemon/1/ | grep -q 'bulbasaur'
postgres:
runs-on: ubuntu-latest
steps:
Expand All @@ -19,16 +37,11 @@ jobs:
- name: Dump DB
run: docker compose exec -T -u postgres db sh -c "cd /tmp && pg_dump -h localhost -Fc -U ash -N 'hdb_*' pokeapi > pokeapi.dump"
- name: Copy dump
run: |
docker compose cp db:/tmp/pokeapi.dump ./
run: docker compose cp db:/tmp/pokeapi.dump ./
- name: Down services
run: docker compose -f docker-compose.yml -f docker-compose-dev.yml down -v
- name: Start services
run: docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
with:
detached: true
- name: Import database
run: |
docker compose cp ./pokeapi.dump db:/tmp/
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,31 @@ jobs:
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build
- name: Start pokeapi (docker)
run: |
docker compose -f docker-compose.yml -f docker-compose-dev.yml up -d
make docker-migrate
make docker-build-db
- name: Dump DB
run: docker compose exec -T -u postgres db sh -c "cd /tmp && pg_dump -h localhost -Fc -U ash pokeapi | gzip > pokeapi.dump.zip"
- name: Copy dump
- name: Dump PG db
run: docker compose exec -T -u postgres db sh -c "cd /tmp && pg_dump -h localhost -Fc -U ash -N 'hdb_*' pokeapi > pokeapi.pgdump"
- name: Copy PG dump
run: |
docker compose cp db:/tmp/pokeapi.dump.zip ./
docker compose cp db:/tmp/pokeapi.pgdump ./
ls -larth
- name: Start pokeapi
run: |
make install
make migrate
make build-db
nohup make serve &
sleep 3
- name: Release
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
fail_on_unmatched_files: true
files: pokeapi.dump.zip
files: |
pokeapi.pgdump
db.sqlite3
generate_release_notes: true

0 comments on commit 9aa187d

Please sign in to comment.