Skip to content

Commit

Permalink
enh(ci): Add rpm delivery cleanup and structure (#499) 2210 (#500)
Browse files Browse the repository at this point in the history
* 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 <dboucher@centreon.com>
  • Loading branch information
3 people committed Mar 14, 2023
1 parent 3b79b40 commit 3bfaedf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
38 changes: 27 additions & 11 deletions .github/actions/delivery/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -94,55 +100,65 @@ runs:
;;
esac
if [[ "${{ env.extfile }}" == "rpm" ]] ; then
eval `ssh-agent`
ssh-add - <<< "${{ inputs.yum_repo_key }}"
fi
FILES="*.${{ env.extfile }}"
for FILE in $FILES
do
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"
echo "[DEBUG] - Target : $TARGET"
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
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/centreon-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
env:
REGISTRY: docker.centreon.com


jobs:
create-version:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -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 }}
Expand Down

0 comments on commit 3bfaedf

Please sign in to comment.