Skip to content

Commit

Permalink
[ci] Save build info
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Portnov <vladimir.portnov@flant.com>
  • Loading branch information
Taior committed Dec 5, 2024
1 parent caa103c commit e4d2f57
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/ci_templates/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ steps:
CI_COMMIT_REF_SLUG: ${{needs.pull_request_info.outputs.ref_slug}}
{!{- end }!}
run: |
DEFAULT_WORKDIR="${{github.workspace}}"
ROOT_WORKDIR=$(dirname "$DEFAULT_WORKDIR")
TEMP_WORKDIR="$ROOT_WORKDIR/${{github.run_id}}-$REGISTRY_SUFFIX"
# Extract REPO_SUFFIX from repository name: trim prefix 'deckhouse/deckhouse-'.
REPO_SUFFIX=${GITHUB_REPOSITORY#deckhouse/deckhouse-}
if [[ $REPO_SUFFIX == $GITHUB_REPOSITORY ]] ; then
Expand Down Expand Up @@ -121,6 +125,7 @@ steps:
# Registry path to publish images for Git tags.
SEMVER_REGISTRY_PATH=
mkdir -p "$TEMP_WORKDIR"
if [[ -n ${DECKHOUSE_REGISTRY_HOST:-} ]] ; then
# Build using dev-registry as primary repo and prod registry as secondary (ro) repo.
# This build will put stages to "dev" registry. If "dev" registry is empty, existing stages are copied from prod registry.
Expand All @@ -135,6 +140,7 @@ steps:
${SECONDARY_REPO} \
--parallel=true --parallel-tasks-limit=5 \
--save-build-report=true \
--tmp-dir="$TEMP_WORKDIR" \
--build-report-path images_tags_werf.json
BRANCH_REGISTRY_PATH="${DEV_REGISTRY_PATH}"
SEMVER_REGISTRY_PATH="${DECKHOUSE_REGISTRY_HOST}/deckhouse"
Expand All @@ -146,12 +152,15 @@ steps:
werf build \
--parallel=true --parallel-tasks-limit=5 \
--save-build-report=true \
--tmp-dir="$TEMP_WORKDIR" \
--build-report-path images_tags_werf.json
BRANCH_REGISTRY_PATH="${DEV_REGISTRY_PATH}"
SEMVER_REGISTRY_PATH="${GHA_TEST_REGISTRY_PATH}"
echo "⚓️ 🧪 [$(date -u)] DECKHOUSE_REGISTRY_HOST is empty. Publish to Github Container Registry '${PROD_REGISTRY_PATH}'"
fi
cp images_tags_werf.json "$TEMP_WORKDIR"
# Publish images for Git branch.
if [[ -n "${CI_COMMIT_BRANCH}" ]]; then
# Add edition name for non-FE builds
Expand Down Expand Up @@ -196,12 +205,15 @@ steps:
if [[ -n ${DECKHOUSE_REGISTRY_HOST} ]] ; then
# Copy stages to prod registry from dev registry.
export WERF_DISABLE_META_TAGS=true
mkdir -p "$TEMP_WORKDIR"
werf build \
--repo ${SEMVER_REGISTRY_PATH}/${REGISTRY_SUFFIX} \
--secondary-repo $WERF_REPO \
--parallel=true --parallel-tasks-limit=5 \
--save-build-report=true \
--tmp-dir="$TEMP_WORKDIR" \
--build-report-path images_tags_werf.json
cp images_tags_werf.json "$TEMP_WORKDIR"
fi
# Note: do not run second werf build for test repo, as it has no secondary repo.

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/build-and-test_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,10 @@ jobs:
CI_COMMIT_REF_NAME: ${{needs.git_info.outputs.ci_commit_ref_name}}
CI_COMMIT_REF_SLUG: ${{needs.pull_request_info.outputs.ref_slug}}
run: |
DEFAULT_WORKDIR="${{github.workspace}}"
ROOT_WORKDIR=$(dirname "$DEFAULT_WORKDIR")
TEMP_WORKDIR="$ROOT_WORKDIR/${{github.run_id}}-$REGISTRY_SUFFIX"
# Extract REPO_SUFFIX from repository name: trim prefix 'deckhouse/deckhouse-'.
REPO_SUFFIX=${GITHUB_REPOSITORY#deckhouse/deckhouse-}
if [[ $REPO_SUFFIX == $GITHUB_REPOSITORY ]] ; then
Expand Down Expand Up @@ -738,6 +742,7 @@ jobs:
# Registry path to publish images for Git tags.
SEMVER_REGISTRY_PATH=
mkdir -p "$TEMP_WORKDIR"
if [[ -n ${DECKHOUSE_REGISTRY_HOST:-} ]] ; then
# Build using dev-registry as primary repo and prod registry as secondary (ro) repo.
# This build will put stages to "dev" registry. If "dev" registry is empty, existing stages are copied from prod registry.
Expand All @@ -752,6 +757,7 @@ jobs:
${SECONDARY_REPO} \
--parallel=true --parallel-tasks-limit=5 \
--save-build-report=true \
--tmp-dir="$TEMP_WORKDIR" \
--build-report-path images_tags_werf.json
BRANCH_REGISTRY_PATH="${DEV_REGISTRY_PATH}"
SEMVER_REGISTRY_PATH="${DECKHOUSE_REGISTRY_HOST}/deckhouse"
Expand All @@ -763,12 +769,15 @@ jobs:
werf build \
--parallel=true --parallel-tasks-limit=5 \
--save-build-report=true \
--tmp-dir="$TEMP_WORKDIR" \
--build-report-path images_tags_werf.json
BRANCH_REGISTRY_PATH="${DEV_REGISTRY_PATH}"
SEMVER_REGISTRY_PATH="${GHA_TEST_REGISTRY_PATH}"
echo "⚓️ 🧪 [$(date -u)] DECKHOUSE_REGISTRY_HOST is empty. Publish to Github Container Registry '${PROD_REGISTRY_PATH}'"
fi
cp images_tags_werf.json "$TEMP_WORKDIR"
# Publish images for Git branch.
if [[ -n "${CI_COMMIT_BRANCH}" ]]; then
# Add edition name for non-FE builds
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/build-and-test_pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ jobs:
CI_COMMIT_REF_NAME: ${{needs.git_info.outputs.ci_commit_ref_name}}
CI_COMMIT_REF_SLUG: ${{needs.git_info.outputs.ci_commit_ref_slug}}
run: |
DEFAULT_WORKDIR="${{github.workspace}}"
ROOT_WORKDIR=$(dirname "$DEFAULT_WORKDIR")
TEMP_WORKDIR="$ROOT_WORKDIR/${{github.run_id}}-$REGISTRY_SUFFIX"
# Extract REPO_SUFFIX from repository name: trim prefix 'deckhouse/deckhouse-'.
REPO_SUFFIX=${GITHUB_REPOSITORY#deckhouse/deckhouse-}
if [[ $REPO_SUFFIX == $GITHUB_REPOSITORY ]] ; then
Expand Down Expand Up @@ -438,6 +442,7 @@ jobs:
# Registry path to publish images for Git tags.
SEMVER_REGISTRY_PATH=
mkdir -p "$TEMP_WORKDIR"
if [[ -n ${DECKHOUSE_REGISTRY_HOST:-} ]] ; then
# Build using dev-registry as primary repo and prod registry as secondary (ro) repo.
# This build will put stages to "dev" registry. If "dev" registry is empty, existing stages are copied from prod registry.
Expand All @@ -452,6 +457,7 @@ jobs:
${SECONDARY_REPO} \
--parallel=true --parallel-tasks-limit=5 \
--save-build-report=true \
--tmp-dir="$TEMP_WORKDIR" \
--build-report-path images_tags_werf.json
BRANCH_REGISTRY_PATH="${DEV_REGISTRY_PATH}"
SEMVER_REGISTRY_PATH="${DECKHOUSE_REGISTRY_HOST}/deckhouse"
Expand All @@ -463,12 +469,15 @@ jobs:
werf build \
--parallel=true --parallel-tasks-limit=5 \
--save-build-report=true \
--tmp-dir="$TEMP_WORKDIR" \
--build-report-path images_tags_werf.json
BRANCH_REGISTRY_PATH="${DEV_REGISTRY_PATH}"
SEMVER_REGISTRY_PATH="${GHA_TEST_REGISTRY_PATH}"
echo "⚓️ 🧪 [$(date -u)] DECKHOUSE_REGISTRY_HOST is empty. Publish to Github Container Registry '${PROD_REGISTRY_PATH}'"
fi
cp images_tags_werf.json "$TEMP_WORKDIR"
# Publish images for Git branch.
if [[ -n "${CI_COMMIT_BRANCH}" ]]; then
# Add edition name for non-FE builds
Expand Down
Loading

0 comments on commit e4d2f57

Please sign in to comment.