diff --git a/.github/workflows/doppler-check.yml b/.github/workflows/doppler-check.yml new file mode 100644 index 0000000..b265f8d --- /dev/null +++ b/.github/workflows/doppler-check.yml @@ -0,0 +1,50 @@ +name: doppler-check + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + validate: + name: Verifica variabili Doppler + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Verifica variabili GitHub + run: | + set -euo pipefail + echo "project: ${DOPPLER_PROJECT}" + echo "config: ${DOPPLER_CONFIG}" + if [ -z "${DOPPLER_PROJECT:-}" ]; then + echo "::error::DOPPLER_PROJECT non impostato" + exit 1 + fi + if [ -z "${DOPPLER_CONFIG:-}" ]; then + echo "::error::DOPPLER_CONFIG non impostata" + exit 1 + fi + if [ -z "${DOPPLER_TOKEN_PRESENT:-}" ]; then + echo "::warning::DOPPLER_TOKEN assente: il fetch non verrà eseguito." + fi + env: + DOPPLER_PROJECT: ${{ vars.DOPPLER_PROJECT }} + DOPPLER_CONFIG: ${{ vars.DOPPLER_CONFIG }} + DOPPLER_TOKEN_PRESENT: ${{ secrets.DOPPLER_TOKEN }} + + - name: Fetch Doppler secrets + if: ${{ secrets.DOPPLER_TOKEN != '' && vars.DOPPLER_PROJECT != '' && vars.DOPPLER_CONFIG != '' }} + uses: dopplerhq/secrets-fetch-action@v2.0.0 + with: + doppler-token: ${{ secrets.DOPPLER_TOKEN }} + project: ${{ vars.DOPPLER_PROJECT }} + config: ${{ vars.DOPPLER_CONFIG }} + inject-env-vars: true + + - name: Skip fetch + if: ${{ secrets.DOPPLER_TOKEN == '' || vars.DOPPLER_PROJECT == '' || vars.DOPPLER_CONFIG == '' }} + run: | + echo "::notice::Doppler fetch saltato: imposta DOPPLER_TOKEN, DOPPLER_PROJECT e DOPPLER_CONFIG nelle impostazioni GitHub." diff --git a/.github/workflows/sentinel.yml b/.github/workflows/sentinel.yml index daded38..54ca5ad 100644 --- a/.github/workflows/sentinel.yml +++ b/.github/workflows/sentinel.yml @@ -28,6 +28,32 @@ jobs: echo "should_run=false" >> "$GITHUB_OUTPUT" fi + - name: Verifica variabili Doppler + if: github.event_name != 'schedule' || steps.schedule.outputs.should_run == 'true' + env: + DOPPLER_PROJECT: ${{ vars.DOPPLER_PROJECT }} + DOPPLER_CONFIG: ${{ vars.DOPPLER_CONFIG }} + DOPPLER_TOKEN_PRESENT: ${{ secrets.DOPPLER_TOKEN }} + run: | + if [ -z "${DOPPLER_PROJECT:-}" ]; then + echo "::warning::DOPPLER_PROJECT non impostato" + fi + if [ -z "${DOPPLER_CONFIG:-}" ]; then + echo "::warning::DOPPLER_CONFIG non impostata" + fi + if [ -z "${DOPPLER_TOKEN_PRESENT:-}" ]; then + echo "::notice::DOPPLER_TOKEN assente: il fetch non verrà eseguito." + fi + + - name: Fetch secrets from Doppler + if: ${{ secrets.DOPPLER_TOKEN != '' && vars.DOPPLER_PROJECT != '' && vars.DOPPLER_CONFIG != '' && (github.event_name != 'schedule' || steps.schedule.outputs.should_run == 'true') }} + uses: dopplerhq/secrets-fetch-action@v2.0.0 + with: + doppler-token: ${{ secrets.DOPPLER_TOKEN }} + project: ${{ vars.DOPPLER_PROJECT }} + config: ${{ vars.DOPPLER_CONFIG }} + inject-env-vars: true + - name: Check email secrets if: github.event_name != 'schedule' || steps.schedule.outputs.should_run == 'true' env: diff --git a/docs/doppler-setup.md b/docs/doppler-setup.md new file mode 100644 index 0000000..7a615df --- /dev/null +++ b/docs/doppler-setup.md @@ -0,0 +1,35 @@ +# Integrazione Doppler + +## Obiettivo +Questo progetto è pronto per l'iniezione dei segreti da Doppler in CI/ambiente runtime. + +## Configurazione GitHub richiesta +1. Crea in Doppler un Project con nome uguale al valore in `DOPPLER_PROJECT`. +2. Crea in quel project la Config da usare in CI (consigliata: `production`) e assegna i segreti nel modo abituale. +3. Crea un Service Token **read-only** per GitHub Actions (`token type: service token`), scope al config corretto. +4. Configura questi segreti/variabili nel repository: + - Secret: `DOPPLER_TOKEN` + - Variable: `DOPPLER_PROJECT` + - Variable: `DOPPLER_CONFIG` + +## Stato attuale repo +- `DOPPLER_PROJECT` impostato a: `Sentinel` +- `DOPPLER_CONFIG` impostato a: `production` + +## Workflow pronto +È stato aggiunto `.github/workflows/doppler-check.yml`. + +### Come usarlo +- Apri la pagina *Actions* della repo e lancia manualmente `doppler-check`. +- Se `DOPPLER_TOKEN`, `DOPPLER_PROJECT` e `DOPPLER_CONFIG` sono corretti, il workflow prova il fetch dei segreti Doppler. + +## Comandi GitHub (facoltativi) + +```bash +gh variable set DOPPLER_PROJECT --body "Sentinel" --repo max23468/Sentinel +gh variable set DOPPLER_CONFIG --body "production" --repo max23468/Sentinel + +gh secret set DOPPLER_TOKEN --body "" --repo max23468/Sentinel +``` + +Sostituisci `` con il token reale del Service Token Doppler.