Skip to content

Instantly share code, notes, and snippets.

@martinmares
Last active April 15, 2025 14:41
Show Gist options
  • Select an option

  • Save martinmares/121bf46d9113b4565813d70586ae6a3a to your computer and use it in GitHub Desktop.

Select an option

Save martinmares/121bf46d9113b4565813d70586ae6a3a to your computer and use it in GitHub Desktop.

Make hook

vi .git/hooks/pre-commit
#!/bin/bash

# Najdi všechny soubory s názvem "env.secured.json" ve staging area (připravené ke commitu)
files=$(git diff --cached --name-only --diff-filter=ACM | grep 'env\.secured\.json$')

# Pokud existují nějaké takové soubory, šifruj je
for file in $files; do
  if [[ -f "$file" ]]; then
    echo "🔐 encrypting ... $file"
    encjson encrypt -f "$file" -w

    # Přidat soubor zpět do stagingu, protože se změnil
    git add "$file"
  fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment