Repository navigation
White label пилот: регистрация, веса и общий рейтинг #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build pilot runtime image | |
| on: | |
| pull_request: | |
| branches: [dev] | |
| paths: | |
| - ".github/workflows/pilot-runtime.yml" | |
| - "procollab/settings_pilot_inline.py" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: pilot-runtime-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| runtime: | |
| name: Export pilot runtime image (no deployment) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Build from tracked source without checkout credentials | |
| shell: bash | |
| run: | | |
| mkdir -p "$RUNNER_TEMP/pilot-source" runtime-artifact | |
| git archive HEAD | tar -x -C "$RUNNER_TEMP/pilot-source" | |
| PILOT_IMAGE="procollab-white-label-pilot-build:$(git rev-parse --short=12 HEAD)" | |
| docker build --label "org.opencontainers.image.revision=$(git rev-parse HEAD)" --tag "$PILOT_IMAGE" "$RUNNER_TEMP/pilot-source" | |
| printf 'PILOT_IMAGE=%s\n' "$PILOT_IMAGE" >> "$GITHUB_ENV" | |
| - name: Check isolated inline profile | |
| run: | | |
| docker run --rm \ | |
| -e DJANGO_SETTINGS_MODULE=procollab.settings_pilot_inline \ | |
| -e DJANGO_SECRET_KEY=ci-only-profile-check \ | |
| -e DATABASE_NAME=procollab_white_label_pilot_ci \ | |
| -e DATABASE_HOST=db \ | |
| -e WHITE_LABEL_ENABLED=True \ | |
| -e WHITE_LABEL_PROGRAM_ID=1 \ | |
| -e WHITE_LABEL_BRAND_NAME=Pilot \ | |
| -e WHITE_LABEL_FRONTEND_URL=https://pilot.procollab.ru \ | |
| "$PILOT_IMAGE" python manage.py check | |
| - name: Export streaming rootfs with provenance and checksum | |
| shell: bash | |
| run: | | |
| PILOT_EXPORT_CONTAINER="$(docker create "$PILOT_IMAGE")" | |
| docker export "$PILOT_EXPORT_CONTAINER" | gzip -1 > runtime-artifact/pilot-api-rootfs.tar.gz | |
| docker rm "$PILOT_EXPORT_CONTAINER" | |
| docker image inspect "$PILOT_IMAGE" > "$RUNNER_TEMP/pilot-image-inspect.json" | |
| python3 - <<'PYINFO' | |
| import hashlib, json, os | |
| from pathlib import Path | |
| import subprocess | |
| info=json.loads(Path(os.environ['RUNNER_TEMP'],'pilot-image-inspect.json').read_text())[0] | |
| archive=Path('runtime-artifact/pilot-api-rootfs.tar.gz') | |
| metadata={ | |
| 'format':'docker-export-v1', | |
| 'image':os.environ['PILOT_IMAGE'].replace('-pilot-build:', '-pilot-api:'), 'image_size_bytes':info['Size'], | |
| 'architecture':info['Architecture'], 'config':info['Config'], | |
| 'api_revision':subprocess.check_output(['git','rev-parse','HEAD'],text=True).strip(), | |
| 'archive_sha256':hashlib.file_digest(archive.open('rb'),'sha256').hexdigest(), | |
| } | |
| Path('runtime-artifact/runtime.json').write_text(json.dumps(metadata,indent=2)+'\n') | |
| PYINFO | |
| (cd runtime-artifact && sha256sum pilot-api-rootfs.tar.gz runtime.json > SHA256SUMS) | |
| - name: Verify streaming import restores image configuration | |
| run: | | |
| python3 deploy/pilot/runtime_import.py --runtime runtime-artifact | |
| PILOT_IMPORTED_IMAGE="$(python3 -c 'import json;print(json.load(open("runtime-artifact/runtime.json"))["image"])')" | |
| docker run --rm \ | |
| -e DJANGO_SETTINGS_MODULE=procollab.settings_ci \ | |
| -e DJANGO_SECRET_KEY=ci-only-import-check \ | |
| "$PILOT_IMPORTED_IMAGE" python manage.py check | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: procollab-pilot-runtime | |
| path: runtime-artifact/ | |
| compression-level: 0 | |
| if-no-files-found: error | |
| retention-days: 7 |