I have a Github Action that needs to grab database dump, put it into dabase, run SQL queries on it, and push the new containerised version of the database to ghcr. How do I push the service container instead of the main one?
What I have right now:
Custom container that has Ubuntu image with python and postgres tools like psql, pg_dump etc.;
Action itself:
name: My action
on: push
jobs:
container-job:
runs-on:
- self-hosted
container: ghcr.io/user/my-container:latest
services:
postgres:
image: postgres:15.3
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
-e POSTGRES_HOST_AUTH_METHOD=trust
-e POSTGRES_DB=somedatabase
-e POSTGRES_USER=someuser
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Create database dump
uses: tj-actions/pg-dump@v2.3
with:
database_url: 'postgres://user@database-host:5432/database-name'
path: 'backups/backup.sql'
options: ''
- name: Restore db data from dump
run: psql -U user -d database-name -h postgres -p 5432 < backups/backup.sql
- name: Modify data
run: python3 my-script-for-connecting-to-db-and-modifying-data.py
docker/build-push-action@v4 seems to be trying to push the ghcr.io/user/my-container:latest instead of the service database unless I'm doing something wrong (which I probably am).