enh(ci): deliver separately to legacy repositories (#4436)

Refs: MON-19115
This commit is contained in:
Kevin Duret 2023-06-01 09:45:34 +02:00 committed by GitHub
parent 6d7d9a809c
commit e4a71322a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 196 additions and 119 deletions

View File

@ -0,0 +1,46 @@
name: "deb-delivery-legacy"
description: "Deliver legacy DEB packages"
inputs:
distrib:
description: "The distribution used for packaging"
required: true
major_version:
description: "The major version"
required: true
nexus_username:
description: The nexus username
required: true
nexus_password:
description: The nexus password
required: true
cache_key:
description: "The cached package key"
required: true
stability:
description: "The package stability (stable, testing, unstable)"
required: true
runs:
using: "composite"
steps:
- name: Use cache DEB files
uses: actions/cache@v3
with:
path: ./*.deb
key: ${{ inputs.cache_key }}
- name: Publish DEBs to Nexus
run: |
echo "Delivering to ${{ inputs.major_version }} ${{ inputs.stability }}"
FOLDER_SUFFIX="-${{ inputs.stability }}"
if [[ "${{ inputs.stability }}" == "stable" ]]; then
FOLDER_SUFFIX=""
fi
for FILE in *.deb; do
sleep 2
echo "Delivering $FILE"
curl --connect-timeout 10 --retry 2 --retry-max-time 30 --fail --silent --show-error -u '${{ inputs.nexus_username }}':'${{ inputs.nexus_password }}' -H 'Content-Type: multipart/form-data' --data-binary "@./$FILE" https://apt.centreon.com/repository/${{ inputs.major_version }}$FOLDER_SUFFIX/ || echo "::error::Fail to deliver $FILE ${{ inputs.major_version }}"
done
shell: bash

View File

@ -1,5 +1,5 @@
name: "deb-package"
description: "Package DEB Centreon"
name: "deb-delivery"
description: "Deliver DEB packages"
inputs:
distrib:
description: "The distribution used for packaging"
@ -38,17 +38,3 @@ runs:
run: |
jf rt upload "*.deb" "apt-plugins-${{ inputs.stability }}/pool/" --deb "${{ inputs.distrib }}/main/all"
shell: bash
- name: Publish DEBs to Nexus
run: |
for MAJOR in "22.04" "22.10"; do
echo "Delivering to $MAJOR ${{ inputs.stability }}"
FOLDER_SUFFIX="-${{ inputs.stability }}"
if [[ "${{ inputs.stability }}" == "stable" ]]; then
FOLDER_SUFFIX=""
fi
find -name "*.deb" -print0 | xargs -0 -t -I % -P 2 sh -c "curl --connect-timeout 10 --retry 2 --retry-max-time 30 --fail --silent --show-error -u '${{ inputs.nexus_username }}':'${{ inputs.nexus_password }}' -H 'Content-Type: multipart/form-data' --data-binary '@%' https://apt.centreon.com/repository/$MAJOR$FOLDER_SUFFIX/ >/dev/null || exit 255" || break
done
shell: bash

View File

@ -0,0 +1,96 @@
name: "rpm-delivery-legacy"
description: "rpm delivery in legacy repositories"
inputs:
module_name:
description: "The package module name"
required: true
major_version:
description: "The major version"
required: true
distrib:
description: "The distribution used for packaging"
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
runs:
using: "composite"
steps:
- name: Use cache RPM files
uses: actions/cache@v3
with:
path: ./*.rpm
key: ${{ inputs.cache_key }}
- 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
run: |
FILES="*.rpm"
REPOTYPE="${{ inputs.stability }}"
PROJECT_PATH="standard"
DISTRIB="${{ inputs.distrib }}"
ARCH="noarch"
eval `ssh-agent`
ssh-add - <<< "${{ inputs.yum_repo_key }}"
echo "Delivering to ${{ inputs.major_version }} $REPOTYPE"
if [ "$REPOTYPE" == "stable" ]; then
TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH/RPMS"
else
TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH/${{ inputs.module_name }}"
PROJECT_LOCATION="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH/${{ inputs.module_name }}"
fi
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"
# Update repository metadata
METADATAS="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH"
sleep $((RANDOM % 120)) # wait random time to avoid simultaneous createrepo
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/${{ inputs.major_version }}/$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

View File

@ -10,21 +10,6 @@ inputs:
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
@ -84,60 +69,3 @@ runs:
fi
done
shell: bash
- 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
run: |
FILES="*.rpm"
REPOTYPE="${{ inputs.stability }}"
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
TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/${{ inputs.module_name }}"
PROJECT_LOCATION="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/$MAJOR/$DISTRIB/$REPOTYPE/$ARCH/${{ inputs.module_name }}"
fi
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"
# 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

View File

@ -75,10 +75,6 @@ jobs:
module_name: connector-vmware
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
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 }}
stability: ${{ needs.get-environment.outputs.stability }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
@ -101,8 +97,6 @@ jobs:
uses: ./.github/actions/deb-delivery
with:
distrib: ${{ matrix.distrib }}
nexus_username: ${{ secrets.NEXUS_USERNAME }}
nexus_password: ${{ secrets.NEXUS_PASSWORD }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
stability: ${{ needs.get-environment.outputs.stability }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}

View File

@ -95,10 +95,6 @@ jobs:
module_name: perl-vmware-vsphere
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
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 }}
stability: ${{ needs.get-environment.outputs.stability }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
@ -121,8 +117,6 @@ jobs:
uses: ./.github/actions/deb-delivery
with:
distrib: ${{ matrix.distrib }}
nexus_username: ${{ secrets.NEXUS_USERNAME }}
nexus_password: ${{ secrets.NEXUS_PASSWORD }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
stability: ${{ needs.get-environment.outputs.stability }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}

View File

@ -77,12 +77,32 @@ jobs:
module_name: plugins
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
stability: ${{ inputs.stability }}
artifactory_token: ${{ secrets.artifactory_token }}
deliver-rpm-legacy:
runs-on: [self-hosted, common]
strategy:
matrix:
distrib: [el7, el8]
major_version: ["21.10", "22.04", "22.10"]
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Delivery
uses: ./.github/actions/rpm-delivery-legacy
with:
module_name: plugins
major_version: ${{ matrix.major_version }}
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
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 }}
stability: ${{ inputs.stability }}
artifactory_token: ${{ secrets.artifactory_token }}
deliver-deb:
runs-on: [self-hosted, common]
@ -98,8 +118,27 @@ jobs:
uses: ./.github/actions/deb-delivery
with:
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
stability: ${{ inputs.stability }}
artifactory_token: ${{ secrets.artifactory_token }}
deliver-deb-legacy:
runs-on: [self-hosted, common]
strategy:
matrix:
distrib: [bullseye]
major_version: ["22.04", "22.10"]
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Delivery
uses: ./.github/actions/deb-delivery-legacy
with:
distrib: ${{ matrix.distrib }}
major_version: ${{ matrix.major_version }}
nexus_username: ${{ secrets.nexus_username }}
nexus_password: ${{ secrets.nexus_password }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
stability: ${{ inputs.stability }}
artifactory_token: ${{ secrets.artifactory_token }}

View File

@ -19,9 +19,6 @@ on:
jobs:
fatpacker:
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.get_version.outputs.version }}
release: ${{ steps.get_version.outputs.release }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
@ -29,17 +26,16 @@ jobs:
fetch-depth: 1
- name: Prepare FatPacker
uses: perl-actions/install-with-cpm@stable
uses: shogo82148/actions-setup-perl@v1
with:
install: |
App::FatPacker
File::Copy::Recursive
JSON
perl-version: '5.34'
install-modules-with: cpm
install-modules: App::FatPacker File::Copy::Recursive JSON
- name: Run FatPacker
run: |
COMMIT=$(git log -1 HEAD --pretty=format:%h)
perl .github/scripts/plugins-source.container.pl "${{ inputs.plugins }}" "${{ steps.get_version.outputs.version }} ($COMMIT)"
perl .github/scripts/plugins-source.container.pl "${{ inputs.plugins }}" "${{ inputs.version }} ($COMMIT)"
- uses: actions/cache@v3
with:

View File

@ -55,19 +55,17 @@ jobs:
- name: transform to directories
run: |
folders=()
for f in ${{ steps.filter.outputs.packages_files }}; \
do \
echo "Adding $(dirname $f) to folders"; \
folders+=($(dirname $f)); \
for f in ${{ steps.filter.outputs.packages_files }}; do
echo "Adding $(dirname $f) to folders"
folders+=($(dirname $f))
done
unique_folders=($(printf "%s\n" "${folders[@]}" | sort -u | tr '\n' ' '))
jq --compact-output --null-input '$ARGS.positional' --args -- ${unique_folders[@]} > package_directories.txt
files=()
for f in ${{ steps.filter.outputs.plugins_files }}; \
do \
echo "Adding $f to files"; \
files+=($f); \
for f in ${{ steps.filter.outputs.plugins_files }}; do
echo "Adding $f to files"
files+=($f)
done
unique_files=($(printf "%s\n" "${files[@]}" | sort -u | tr '\n' ' '))
jq --compact-output --null-input '$ARGS.positional' --args -- ${unique_files[@]} > plugins.txt