Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh(ci): Add rpm delivery cleanup and structure (#499) 2210 #500

Merged
merged 5 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion .github/actions/runner-docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ inputs:
required: false

env:
REGISTRY: registry-docker.centreon.com/docker-global
REGISTRY: docker.centreon.com

runs:
using: "composite"
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/centreon-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- dev-22.10.x

env:
REGISTRY: registry-docker.centreon.com/docker-global
REGISTRY: docker.centreon.com

jobs:
create-version:
Expand Down Expand Up @@ -213,6 +213,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 All @@ -221,4 +223,4 @@ jobs:
cloudfront_id: ${{ secrets.CLOUDFRONT_ID }}
yum_repo_address: ${{ secrets.YUM_REPO_ADDRESS }}
yum_repo_key: ${{ secrets.YUM_REPO_KEY }}
yum_repo_url: ${{ secrets.YUM_REPO_URL }}
yum_repo_url: ${{ secrets.YUM_REPO_URL }}
2 changes: 1 addition & 1 deletion .github/workflows/docker-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
- 'ci/docker/**'

env:
REGISTRY: registry-docker.centreon.com/docker-global
REGISTRY: docker.centreon.com

jobs:
create-version:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/robot-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- cron: '0 0 * * *'

env:
REGISTRY: registry-docker.centreon.com/docker-global
REGISTRY: docker.centreon.com

jobs:
robot-test:
Expand Down