✨ feat(ci): workflow Python con registry PyPI privato di Gitea
- nuovo input opzionale extra-index-gitea (default false, retrocompatibile) in python-quality-gates, python-docker-release, python-dependency-check e python-dependency-outdated - le credenziali G_USER / NPM_TOKEN finiscono in un netrc 600 in $RUNNER_TEMP (NETRC): PIP_EXTRA_INDEX_URL resta senza segreti, niente token nell'env o nei log - python-docker-release passa lo stesso file a BuildKit come secret pip_netrc (secret-files), da montare con RUN --mount=type=secret: il token non entra negli strati dell'immagine - il netrc viene rimosso a fine job (always) Fixes #17 @1h30m
This commit is contained in:
1 parent
195407f04c
commit
4b2d986929
4 files changed
+125
No files matched your search
@@ -12,6 +12,12 @@ on:
|
||||
working-directory:
|
||||
type: string
|
||||
default: '.'
|
||||
extra-index-gitea:
|
||||
description: >-
|
||||
Aggiunge il registry PyPI privato di Gitea (PZeta_Touch) come indice extra di pip,
|
||||
autenticato con i secrets G_USER / NPM_TOKEN (serve 'secrets: inherit').
|
||||
type: boolean
|
||||
default: false
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
@@ -29,6 +35,26 @@ jobs:
|
||||
with:
|
||||
python-version: ${{ inputs.python-version || '3.11' }}
|
||||
|
||||
# Registry PyPI privato di Gitea (#17). Le credenziali vanno in un file netrc e non
|
||||
# nell'URL: PIP_EXTRA_INDEX_URL resta senza segreti, pip legge utente e token dal file
|
||||
# indicato da NETRC, e nulla di sensibile passa per l'env esportato o per i log.
|
||||
- name: Registry PyPI di Gitea
|
||||
id: pypi-gitea
|
||||
if: ${{ inputs.extra-index-gitea }}
|
||||
env:
|
||||
G_USER: ${{ secrets.G_USER }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
if [ -z "$G_USER" ] || [ -z "$NPM_TOKEN" ]; then
|
||||
echo "::error::extra-index-gitea richiede i secrets G_USER e NPM_TOKEN: serve 'secrets: inherit' nel workflow chiamante."
|
||||
exit 1
|
||||
fi
|
||||
NETRC_FILE="$RUNNER_TEMP/pip-gitea.netrc"
|
||||
( umask 077; printf 'machine gitea.pzetatouch.it\nlogin %s\npassword %s\n' "$G_USER" "$NPM_TOKEN" > "$NETRC_FILE" )
|
||||
echo "NETRC=$NETRC_FILE" >> "$GITHUB_ENV"
|
||||
echo "PIP_EXTRA_INDEX_URL=https://gitea.pzetatouch.it/api/packages/PZeta_Touch/pypi/simple/" >> "$GITHUB_ENV"
|
||||
echo "netrc=$NETRC_FILE" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Cache pip
|
||||
uses: https://github.com/actions/cache@v4
|
||||
with:
|
||||
@@ -106,3 +132,7 @@ jobs:
|
||||
\"body\": $(jq -Rs . /tmp/body.md)
|
||||
}"
|
||||
fi
|
||||
|
||||
- name: Rimozione credenziali registry PyPI
|
||||
if: ${{ always() && inputs.extra-index-gitea }}
|
||||
run: rm -f "$RUNNER_TEMP/pip-gitea.netrc"
|
||||
Reference in new issue
Block a user