Skip to content

Commit

Permalink
fix(delivery): add delivery to old yum repo (#456)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuntoja authored and bouda1 committed Mar 14, 2023
1 parent cf80d85 commit 9a45c8d
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 10 deletions.
80 changes: 71 additions & 9 deletions .github/actions/delivery/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: "delivery"
description: "RPM and DEB packages delivery Centreon"
inputs:
module_name:
description: "The name of the module"
required: true
distrib:
description: "The distribution used for packaging"
required: true
Expand All @@ -16,6 +19,21 @@ inputs:
cache_key:
description: "The cached package key"
required: true
update_repo_path:
description: "The update repo script path"
required: true
cloudfront_id:
description: "The cloudfront ID for repo url"
required: true
yum_repo_address:
description: "The yum legacy repo address"
required: true
yum_repo_key:
description: "The yum repo key"
required: true
yum_repo_url:
description: "The legacy yum repo url"
required: true

runs:
using: "composite"
Expand All @@ -41,6 +59,13 @@ runs:
key: ${{ inputs.cache_key }}-${{ env.build }}-${{ inputs.distrib }}
restore-keys: ${{ inputs.cache_key }}-${{ env.build }}-${{ inputs.distrib }}

- name: Setup awscli
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
sudo unzip -q awscliv2.zip
sudo ./aws/install
shell: bash

- name: Publish packages
run: |
if [[ -z "$GITHUB_HEAD_REF" ]];
Expand All @@ -52,35 +77,72 @@ runs:
echo "[DEBUG] - Branch name: $BRANCHNAME"
case "$BRANCHNAME" in
develop | dev-[2-9][0-9].[0-9][0-9].x)
REPO="unstable"
SUBREPO="unstable"
;;
release* | hotfix*)
REPO="testing"
SUBREPO="testing"
;;
master | [2-9][0-9].[0-9][0-9].x)
REPO="stable"
SUBREPO="stable"
;;
*)
echo -n "[INFO] NO DELIVERY FOR THIS BRANCH"
exit 0
;;
esac
FILES="*.${{ env.extfile }}";
DISTRIB="${{ inputs.distrib }}";
echo "[DEBUG] - Repo: $REPO"
echo "[DEBUG] - FILES: $FILES"
echo "[DEBUG] - DISTRIB: $DISTRIB"
for FILE in $FILES
do
echo "[DEBUG] - File: $FILE"
VERSION=${{ inputs.version }}
MAJOR="$VERSION"
DISTRIB="${{ inputs.distrib }}";
REPOTYPE="$SUBREPO"
ARCH=$(echo $FILE | grep -oP '(x86_64|noarch)')
PROJECT=${{ inputs.module_name }}
FOLDER=$(basename $FILE .rpm)
PROJECT_PATH="standard"
echo "[DEBUG] - Arch: $ARCH"
echo "[DEBUG] - Suprepo: $SUBREPO"
echo "[DEBUG] - FILES: $FILES"
echo "[DEBUG] - DISTRIB: $DISTRIB"
echo "[DEBUG] - Version: $VERSION"
if [[ "${{ env.extfile }}" == "deb" ]] ; then
echo "[DEBUG] - https://artifactory.apps.centreon.com/artifactory/debian-$VERSION-$REPO/pool/$FILE;deb.distribution=bullseye;deb.component=main;deb.architecture=amd64"
curl -v -u "${{ inputs.repos_username }}":"${{ inputs.repos_password }}" -X PUT "https://artifactory.apps.centreon.com/artifactory/debian-$VERSION-$REPO/pool/$FILE;deb.distribution=bullseye;deb.component=main;deb.architecture=amd64" -T "./$FILE"
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"
#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"
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"
METADATAS="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH"
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"
ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" "sh "${{ inputs.update_repo_path }}" $METADATAS" 2>&-
fi
done
ID="${{ inputs.cloudfront_id }}"
PATHS="/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/*"
ITERATIONS=1
until aws cloudfront create-invalidation --distribution-id "$ID" --paths "$PATHS"; do
if [ ${ITERATIONS} -eq 10 ]; then
return 0
fi
echo "couldn't invalidate cache, AWS quota might have been reached, retrying in 30 seconds..."
sleep 30s
ITERATIONS=$((ITERATIONS+1))
done
shell: bash
8 changes: 7 additions & 1 deletion .github/workflows/centreon-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
echo "release=$GITHUB_RUN_ATTEMPT" >> $GITHUB_OUTPUT
;;
*)
echo "release=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "release=`date +%s`.`echo ${{ github.sha }} | cut -c -7`" >> $GITHUB_OUTPUT
;;
esac
shell: bash
Expand Down Expand Up @@ -211,6 +211,12 @@ jobs:
with:
distrib: ${{ matrix.distrib }}
version: ${{ env.version }}
module_name: centreon-collect
repos_username: ${{ secrets.REPOS_USERNAME }}
repos_password: ${{ secrets.REPOS_PASSWORD }}
cache_key: cache-${{ github.sha }}-${{ github.run_id }}
update_repo_path: ${{ secrets.UPDATE_REPO_PATH }}
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 }}

0 comments on commit 9a45c8d

Please sign in to comment.