centreon-plugins/.github/actions/rpm-delivery/action.yml

124 lines
4.1 KiB
YAML
Raw Normal View History

2023-01-10 15:03:40 +01:00
name: "rpm-delivery"
description: "rpm delivery"
inputs:
distrib:
description: "The distribution used for packaging"
required: true
version:
description: "Centreon packaged version"
required: true
release:
description: The release number
required: true
cache_key:
description: "The cached package key"
required: true
yum_repo_url:
description: "The legacy yum repo url"
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 legacy yum repo address"
required: true
yum_repo_key:
description: "The repo key"
required: true
stability:
description: "The package stability (stable, testing, unstable)"
required: true
artifactory_token:
description: "token for artifactory"
required: true
2023-01-10 15:03:40 +01:00
runs:
using: "composite"
steps:
- name: Use cache RPM files
uses: actions/cache@v3
with:
path: ./*.rpm
key: ${{ inputs.cache_key }}
- uses: jfrog/setup-jfrog-cli@v3
env:
JF_URL: https://centreon.jfrog.io
JF_ACCESS_TOKEN: ${{ inputs.artifactory_token }}
- name: Publish RPMs to plugins repository
run: |
jf rt upload "*.rpm" "rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/noarch/"
shell: bash
2023-01-10 15:03:40 +01:00
- 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 RPMs to standard repositories
2023-01-10 15:03:40 +01:00
run: |
FILES="*.rpm"
VERSION="${{ inputs.version }}"
RELEASE="${{ inputs.release }}"
REPOTYPE="${{ inputs.stability }}"
PROJECT="plugins"
PROJECT_PATH="standard"
DISTRIB="${{ inputs.distrib }}"
ARCH="noarch"
eval `ssh-agent`
ssh-add - <<< "${{ inputs.yum_repo_key }}"
for MAJOR in "21.10" "22.04" "22.10"; do
echo "::group::Delivering to $MAJOR $REPOTYPE"
if [ "$REPOTYPE" == "stable" ]; then
TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/RPMS"
else
FOLDER="centreon-$PROJECT-$VERSION-$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"
scp -o StrictHostKeyChecking=no ./*.rpm "${{ inputs.yum_repo_address }}:$TARGET"
# Cleanup is done on unstable repository only
#if [ "$REPOTYPE" == "unstable" ]; then
# ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" "ls -drc $PROJECT_LOCATION/* 2>&- | head -n -1 | xargs rm -rf"
#fi
2023-01-10 15:03:40 +01:00
# 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
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
echo "::endgroup::"
done
shell: bash