From d5bb8a5ba6bbd7232cdf708456cd18c55e53c920 Mon Sep 17 00:00:00 2001 From: tuntoja <58987095+tuntoja@users.noreply.github.com> Date: Mon, 9 Jan 2023 12:14:09 +0100 Subject: [PATCH] enh(ci): Add rpm delivery cleanup and structure (#499) 2210 (#500) * enh(ci): Add rpm delivery cleanup and structure (#499) * enh(ci): Add rpm delivery cleanup and structure * Add version to delivery inputs * Add condition to use sshkey for rpm delivery only * Update delivery action * Update action delivery * Update action delivery * Update action delivery * Update action delivery * Update action delivery * Enable cleanup * Update action.yml * Update action.yml * Update action.yml * fix(ci): correct docker registry link (#494) * fix(ci): correct docker registry link * Update action.yml Fix run folder naming * fix(conan): path updated to find protoc Co-authored-by: Charles Gautier <33026375+chgautier@users.noreply.github.com> Co-authored-by: David Boucher --- .github/actions/delivery/action.yml | 38 ++++++++++++++++++-------- .github/workflows/centreon-collect.yml | 3 ++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.github/actions/delivery/action.yml b/.github/actions/delivery/action.yml index b9ec9073d40..1d0ae4d61d8 100644 --- a/.github/actions/delivery/action.yml +++ b/.github/actions/delivery/action.yml @@ -19,6 +19,12 @@ inputs: version: description: "Centreon packaged version" required: true + minor_version: + description: "Centreon packaged version" + required: true + release: + description: The release number + required: true cache_key: description: "The cached package key" required: true @@ -94,6 +100,11 @@ runs: ;; esac + if [[ "${{ env.extfile }}" == "rpm" ]] ; then + eval `ssh-agent` + ssh-add - <<< "${{ inputs.yum_repo_key }}" + fi + FILES="*.${{ env.extfile }}" for FILE in $FILES @@ -101,32 +112,31 @@ runs: echo "[DEBUG] - File: $FILE" VERSION=${{ inputs.version }} MAJOR="$VERSION" + MINOR=${{ inputs.minor_version }} + RELEASE=${{ inputs.release }} REPOTYPE="$SUBREPO" PROJECT=${{ inputs.module_name }} PROJECT_PATH="standard" echo "[DEBUG] - Suprepo: $SUBREPO" - echo "[DEBUG] - FILES: $FILES" echo "[DEBUG] - Version: $VERSION" if [[ "${{ env.extfile }}" == "deb" ]] ; then curl -u "${{ inputs.repos_username }}":"${{ inputs.repos_password }}" -H "Content-Type: multipart/form-data" --data-binary "@./$FILE" https://apt.centreon.com/repository/22.10-$SUBREPO/ else - #echo "[DEBUG] - https://artifactory.apps.centreon.com/artifactory/rpm-$VERSION-$REPO/$DISTRIB/$REPO/x86_64/centreon-collect" - #curl -v -u "${{ inputs.repos_username }}":"${{ inputs.repos_password }}" -X PUT "https://artifactory.apps.centreon.com/artifactory/rpm-$VERSION-$REPO/$DISTRIB/$REPO/x86_64/centreon-collect/$FILE" -T "./$FILE" - DISTRIB="${{ inputs.distrib }}" ARCH=$(echo $FILE | grep -oP '(x86_64|noarch)') - FOLDER=$(basename $FILE .rpm) echo "[DEBUG] - DISTRIB: $DISTRIB" echo "[DEBUG] - Arch: $ARCH" - echo "[DEBUG] - FOLDER: $FOLDER" - eval `ssh-agent` - ssh-add - <<< "${{ inputs.yum_repo_key }}" - TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/$PROJECT/$FOLDER" - PROJECT_LOCATION="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/$PROJECT" + if [[ "$SUBREPO" == "stable" ]] ; then + TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/RPMS" + else + FOLDER="$PROJECT-$MAJOR.$MINOR-$RELEASE" + TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/$PROJECT/$FOLDER" + PROJECT_LOCATION="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/$PROJECT" + fi echo "[DEBUG] - Folder: $FOLDER" echo "[DEBUG] - Project : $PROJECT" @@ -134,15 +144,21 @@ runs: echo "[DEBUG] - PROJECT_LOCATION : $PROJECT_LOCATION" ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" mkdir -p "$TARGET" 2>&- scp -o StrictHostKeyChecking=no "$FILE" "${{ inputs.yum_repo_address }}:$TARGET" 2>&- - #ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" "ls -drc $PROJECT_LOCATION/* 2>&- | head -n -6 | xargs rm -rf" fi done # run this only for rpm if [[ "${{ env.extfile }}" == "rpm" ]] ; then + # Cleanup is done on unstable repository only + if [[ "$SUBREPO" == "unstable" ]] ; then + ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" "ls -drc $PROJECT_LOCATION/* 2>&- | head -n -1 | xargs rm -rf" + fi + + # Update repository metadata METADATAS="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH" ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" "sh "${{ inputs.update_repo_path }}" $METADATAS" 2>&- + # Invalidate cloudfront cache ID="${{ inputs.cloudfront_id }}" PATHS="/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/*" ITERATIONS=1 diff --git a/.github/workflows/centreon-collect.yml b/.github/workflows/centreon-collect.yml index bf3472c36d8..4dd98133afb 100644 --- a/.github/workflows/centreon-collect.yml +++ b/.github/workflows/centreon-collect.yml @@ -10,6 +10,7 @@ on: env: REGISTRY: docker.centreon.com + jobs: create-version: runs-on: ubuntu-latest @@ -213,6 +214,8 @@ jobs: with: distrib: ${{ matrix.distrib }} version: ${{ env.version }} + minor_version: ${{ needs.create-version.outputs.patch }} + release: ${{ needs.create-version.outputs.release }} module_name: centreon-collect repos_username: ${{ secrets.REPOS_USERNAME }} repos_password: ${{ secrets.REPOS_PASSWORD }}