CI and CD
Running Safeslice in a pipeline — refreshing preview environments, gating on the privacy scan, and keeping credentials out of logs.
The wizard is for humans. In a pipeline you want the two commands it drives.
safeslice run --config safeslice.yaml --to "$DATABASE_URL"
safeslice verify --target "$DATABASE_URL"
verify exits non-zero on any finding, so it gates a job without extra scripting.
GitHub Actions
name: refresh-preview-database
on:
workflow_dispatch:
schedule: [{ cron: "0 4 * * 1" }]
jobs:
slice:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install safeslice
run: |
curl -sSfL https://github.com/Autometiq/safeslice/releases/latest/download/safeslice_linux_amd64.tar.gz | tar xz
sudo mv safeslice /usr/local/bin/
- name: Slice and mask
env:
SAFESLICE_SOURCE: ${{ secrets.REPLICA_URL }}
DATABASE_URL: ${{ secrets.PREVIEW_URL }}
run: safeslice run --config safeslice.yaml --to "$DATABASE_URL" --quiet
- name: Verify no personal data survived
env:
DATABASE_URL: ${{ secrets.PREVIEW_URL }}
run: safeslice verify --target "$DATABASE_URL"
- uses: actions/upload-artifact@v4
if: always()
with:
name: safeslice-report
path: safeslice-output/
Point SAFESLICE_SOURCE at a read replica. Safeslice opens it read-only, but a replica also means a long walk cannot compete with production traffic.
Docker
docker run --rm \
-e SAFESLICE_SOURCE \
-v "$PWD:/work" -w /work \
ghcr.io/autometiq/safeslice:latest \
run --to "$DATABASE_URL" --quiet
Keeping logs clean
- Use
--quietto drop the banner and footer. - Output is plain and un-styled automatically when it is not a terminal, so no ANSI escapes reach your log.
- Connection strings are redacted to host, port, database and user everywhere they appear. Passing a DSN through a secret still keeps it out of the log.
Asserting on the result
summary.json is written for exactly this:
jq -e '.verification.passed and .foreign_key_orphans == 0' safeslice-output/summary.json
Attach safeslice-output/ as a build artifact and every refresh leaves an auditable record of what was copied and what was masked.
Determinism
Pin mask.seed in safeslice.yaml and the same source produces the same masked values on every run. Tests that assert on a masked value keep passing; a changed seed changes everything, which is what you want when rotating.