Transfer source checkout through Docker API
Some checks failed
Build and publish policy-nexus image / build-and-push (push) Failing after 44s
Some checks failed
Build and publish policy-nexus image / build-and-push (push) Failing after 44s
This commit is contained in:
parent
093913719f
commit
e33b98a1e6
1 changed files with 21 additions and 10 deletions
|
|
@ -44,7 +44,14 @@ jobs:
|
||||||
test "${#REF}" -eq 40
|
test "${#REF}" -eq 40
|
||||||
SHORT="${REF:0:7}"
|
SHORT="${REF:0:7}"
|
||||||
BUILD_ROOT="$(mktemp -d)"
|
BUILD_ROOT="$(mktemp -d)"
|
||||||
trap 'rm -rf "${BUILD_ROOT}"' EXIT
|
PYTHON_CONTAINER=""
|
||||||
|
cleanup() {
|
||||||
|
if [ -n "${PYTHON_CONTAINER}" ] && [ -x "${HOME}/bin/docker" ]; then
|
||||||
|
"${HOME}/bin/docker" rm -f "${PYTHON_CONTAINER}" >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
rm -rf "${BUILD_ROOT}"
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
BUILD_CONTEXT="${BUILD_ROOT}/buildctx"
|
BUILD_CONTEXT="${BUILD_ROOT}/buildctx"
|
||||||
mkdir -p "${BUILD_CONTEXT}" "${HOME}/bin"
|
mkdir -p "${BUILD_CONTEXT}" "${HOME}/bin"
|
||||||
|
|
||||||
|
|
@ -58,16 +65,20 @@ jobs:
|
||||||
export PATH="${HOME}/bin:${PATH}"
|
export PATH="${HOME}/bin:${PATH}"
|
||||||
docker version
|
docker version
|
||||||
PYTHON_IMAGE="docker.io/library/python@sha256:d09d15e60962ca365d1cd544a48773bac9d33f2fb1b00f2aa0deec78ade7dc31"
|
PYTHON_IMAGE="docker.io/library/python@sha256:d09d15e60962ca365d1cd544a48773bac9d33f2fb1b00f2aa0deec78ade7dc31"
|
||||||
docker run --rm \
|
PYTHON_CONTAINER="policy-source-fetch-${SHORT}-${GITHUB_RUN_ID:-0}"
|
||||||
--volume "${BUILD_CONTEXT}:/workspace" \
|
docker create --name "${PYTHON_CONTAINER}" "${PYTHON_IMAGE}" sleep 300
|
||||||
--workdir /workspace \
|
docker cp "${BUILD_CONTEXT}/." "${PYTHON_CONTAINER}:/workspace"
|
||||||
"${PYTHON_IMAGE}" \
|
docker start "${PYTHON_CONTAINER}"
|
||||||
|
docker exec --workdir /workspace "${PYTHON_CONTAINER}" \
|
||||||
python3 tools/fetch_sources.py \
|
python3 tools/fetch_sources.py \
|
||||||
--config source-inventory.config.json \
|
--config source-inventory.config.json \
|
||||||
--destination _sources \
|
--destination _sources \
|
||||||
--policy-revision "${REF}"
|
--policy-revision "${REF}"
|
||||||
NETKINGDOM_REVISION="$(docker run --rm --volume "${BUILD_CONTEXT}:/workspace" "${PYTHON_IMAGE}" python3 -c 'import json; print(json.load(open("/workspace/_sources/source-lock.json"))["repositories"]["net-kingdom"]["revision"])')"
|
NETKINGDOM_REVISION="$(docker exec "${PYTHON_CONTAINER}" python3 -c 'import json; print(json.load(open("/workspace/_sources/source-lock.json"))["repositories"]["net-kingdom"]["revision"])')"
|
||||||
SOURCE_SET_DIGEST="$(docker run --rm --volume "${BUILD_CONTEXT}:/workspace" "${PYTHON_IMAGE}" python3 -c 'import json; print(json.load(open("/workspace/_sources/source-lock.json"))["source_set_digest"])')"
|
SOURCE_SET_DIGEST="$(docker exec "${PYTHON_CONTAINER}" python3 -c 'import json; print(json.load(open("/workspace/_sources/source-lock.json"))["source_set_digest"])')"
|
||||||
|
docker cp "${PYTHON_CONTAINER}:/workspace/_sources" "${BUILD_CONTEXT}/"
|
||||||
|
docker rm -f "${PYTHON_CONTAINER}"
|
||||||
|
PYTHON_CONTAINER=""
|
||||||
SOURCE_TAG="source-${SOURCE_SET_DIGEST}"
|
SOURCE_TAG="source-${SOURCE_SET_DIGEST}"
|
||||||
REVISION_TAG="git-${REF}-sources-${SOURCE_SET_DIGEST:0:16}"
|
REVISION_TAG="git-${REF}-sources-${SOURCE_SET_DIGEST:0:16}"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue