mirror of
https://github.com/prodrigestivill/docker-postgres-backup-local.git
synced 2026-05-31 08:37:58 +00:00
103 lines
2.7 KiB
YAML
103 lines
2.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
jobs:
|
|
test-script:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgres:latest
|
|
env:
|
|
POSTGRES_DB: "database"
|
|
POSTGRES_USER: "user"
|
|
POSTGRES_PASSWORD: "test"
|
|
ports:
|
|
- 5432:5432
|
|
# Set health checks to wait until postgres has started
|
|
options:
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Test backup script
|
|
env:
|
|
POSTGRES_DB: "database"
|
|
POSTGRES_USER: "user"
|
|
POSTGRES_PASSWORD: "test"
|
|
POSTGRES_HOST: "127.0.0.1"
|
|
POSTGRES_PORT: 5432
|
|
POSTGRES_EXTRA_OPTS: "-Z0"
|
|
BACKUP_DIR: ".data"
|
|
# Defaults
|
|
POSTGRES_DB_FILE: "**None**"
|
|
POSTGRES_USER_FILE: "**None**"
|
|
POSTGRES_PASSWORD_FILE: "**None**"
|
|
POSTGRES_PASSFILE_STORE: "**None**"
|
|
POSTGRES_CLUSTER: "FALSE"
|
|
BACKUP_SUFFIX: ".sql.gz"
|
|
BACKUP_KEEP_DAYS: 7
|
|
BACKUP_KEEP_WEEKS: 4
|
|
BACKUP_KEEP_MONTHS: 6
|
|
run: |
|
|
echo "Test backup script..."
|
|
mkdir -p "$BACKUP_DIR"
|
|
sh -xe backup.sh
|
|
echo "Generated backup files:"
|
|
ls -laR "$BACKUP_DIR"
|
|
|
|
test-docker:
|
|
if: ${{ github.event_name == 'pull_request' || github.ref != 'refs/heads/main' }}
|
|
needs: [ test-script ]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
- name: Test docker images build
|
|
run: docker buildx bake --pull
|
|
|
|
publish:
|
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
|
needs: [ test-script ]
|
|
runs-on: ubuntu-latest
|
|
environment: docker.io
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Configure build revision
|
|
id: vars
|
|
run: echo "::set-output name=sha_short::${GITHUB_SHA:0:7}"
|
|
|
|
- name: Build images
|
|
env:
|
|
BUILDREV: ${{ steps.vars.outputs.sha_short }}
|
|
run: docker buildx bake --pull
|
|
|
|
- name: Push images
|
|
env:
|
|
BUILDREV: ${{ steps.vars.outputs.sha_short }}
|
|
run: docker buildx bake --push
|