enh(ci): move all deliveries to artifactory (#4687)

* move all deliveries to artifactory
* do not delivery nrpe service configuration
Refs: MON-22360
This commit is contained in:
Kevin Duret 2023-10-09 09:21:46 +02:00 committed by GitHub
parent 842f00d558
commit ac65fd0ddc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 74 additions and 115 deletions

View File

@ -1,24 +1,24 @@
name: "deb-delivery-legacy"
description: "Deliver legacy DEB packages"
inputs:
module_name:
description: "The package module name"
required: true
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
artifactory_token:
description: "token for artifactory"
required: true
runs:
using: "composite"
@ -30,18 +30,20 @@ runs:
key: ${{ inputs.cache_key }}
fail-on-cache-miss: true
- name: Publish DEBs to Nexus
- uses: jfrog/setup-jfrog-cli@v3
env:
JF_URL: https://centreon.jfrog.io
JF_ACCESS_TOKEN: ${{ inputs.artifactory_token }}
- name: Publish DEBs to artifactory
run: |
echo "Delivering to ${{ inputs.major_version }} ${{ inputs.stability }}"
FILES="*.deb"
FOLDER_SUFFIX="-${{ inputs.stability }}"
if [[ "${{ inputs.stability }}" == "stable" ]]; then
FOLDER_SUFFIX=""
fi
for FILE in $FILES; do
echo "[DEBUG] - File: $FILE"
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 }}"
ARCH=$(echo $FILE | cut -d '_' -f3 | cut -d '.' -f1)
jf rt upload "$FILE" "apt-standard-${{ inputs.major_version }}-${{ inputs.stability }}/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/$ARCH"
done
shell: bash

View File

@ -1,15 +1,12 @@
name: "deb-delivery"
description: "Deliver DEB packages"
inputs:
module_name:
description: "The package module name"
required: true
distrib:
description: "The distribution used for packaging"
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
@ -37,5 +34,13 @@ runs:
- name: Publish DEBs to artifactory
run: |
jf rt upload "*.deb" "apt-plugins-${{ inputs.stability }}/pool/" --deb "${{ inputs.distrib }}/main/all"
FILES="*.deb"
for FILE in $FILES; do
echo "[DEBUG] - File: $FILE"
ARCH=$(echo $FILE | cut -d '_' -f3 | cut -d '.' -f1)
jf rt upload "$FILE" "apt-plugins-${{ inputs.stability }}/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/$ARCH"
done
shell: bash

View File

@ -30,7 +30,8 @@ runs:
sudo ./aws/install
shell: bash
- run: |
- name: Publish on download.centreon.com
run: |
SRC_FILE="${{ inputs.module_name }}-${{ inputs.version }}.tar.gz"
mv "${{ inputs.module_directory }}" "${{ inputs.module_name }}-${{ inputs.version }}"

View File

@ -13,24 +13,12 @@ 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
artifactory_token:
description: "token for artifactory"
required: true
runs:
using: "composite"
@ -42,56 +30,46 @@ runs:
key: ${{ inputs.cache_key }}
fail-on-cache-miss: true
- 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
- uses: jfrog/setup-jfrog-cli@v3
env:
JF_URL: https://centreon.jfrog.io
JF_ACCESS_TOKEN: ${{ inputs.artifactory_token }}
- name: Publish RPMs to standard repositories
- name: Publish RPMs to standard repository
run: |
FILES="*.rpm"
REPOTYPE="${{ inputs.stability }}"
PROJECT_PATH="standard"
DISTRIB="${{ inputs.distrib }}"
ARCH="noarch"
echo "[DEBUG] - Distrib: ${{ inputs.distrib }}"
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 }}"
if [ -z "${{ inputs.module_name }}" ]; then
echo "::error::Module name is required"
exit 1
fi
echo "[DEBUG] - Target : $TARGET"
echo "[DEBUG] - PROJECT_LOCATION : $PROJECT_LOCATION"
if [ -z "${{ inputs.distrib }}" ]; then
echo "::error::Distrib is required"
exit 1
fi
ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" mkdir -p "$TARGET"
scp -o StrictHostKeyChecking=no ./*.rpm "${{ inputs.yum_repo_address }}:$TARGET"
mkdir noarch x86_64
# 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>&-
for FILE in $FILES; do
echo "[DEBUG] - File: $FILE"
# Invalidate cloudfront cache
ID="${{ inputs.cloudfront_id }}"
PATHS="/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH/*"
ITERATIONS=1
ARCH=$(echo $FILE | grep -oP '(x86_64|noarch)')
until aws cloudfront create-invalidation --distribution-id "$ID" --paths "$PATHS"; do
if [ ${ITERATIONS} -eq 10 ]; then
return 0
echo "[DEBUG] - Arch: $ARCH"
cp "$FILE" "$ARCH"
done
for ARCH in "noarch" "x86_64"; do
if [ "$(ls -A $ARCH)" ]; then
if [ "${{ inputs.stability }}" == "stable" ]; then
jf rt upload "$ARCH/*.rpm" "rpm-standard/${{ inputs.major_version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/RPMS/${{ inputs.module_name }}/" --flat
else
jf rt upload "$ARCH/*.rpm" "rpm-standard/${{ inputs.major_version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/${{ inputs.module_name }}/" --flat
fi
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

@ -63,7 +63,7 @@ runs:
for ARCH in "noarch" "x86_64"; do
if [ "$(ls -A $ARCH)" ]; then
if [ "${{ inputs.stability }}" == "stable" ]; then
jf rt upload "$ARCH/*.rpm" "rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/" --flat
jf rt upload "$ARCH/*.rpm" "rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/RPMS/${{ inputs.module_name }}/" --flat
else
jf rt upload "$ARCH/*.rpm" "rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/${{ inputs.module_name }}/" --flat
fi

View File

@ -17,8 +17,6 @@ on:
paths:
- 'connectors/vmware/src/**'
- 'connectors/vmware/packaging/**'
tags:
- centreon-connector-vmware-*
jobs:
get-environment:
@ -111,6 +109,7 @@ jobs:
- name: Delivery
uses: ./.github/actions/deb-delivery
with:
module_name: connector-vmware
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
stability: ${{ needs.get-environment.outputs.stability }}

View File

@ -15,8 +15,6 @@ on:
- master
paths:
- 'nrpe/packaging/**'
tags:
- centreon-nrpe-*
jobs:
get-environment:
@ -147,6 +145,7 @@ jobs:
- name: Delivery
uses: ./.github/actions/deb-delivery
with:
module_name: nrpe
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
stability: ${{ needs.get-environment.outputs.stability }}

View File

@ -15,8 +15,6 @@ on:
- master
paths:
- 'dependencies/perl-vmware-vsphere/**'
tags:
- perl-vmware-vsphere-*
jobs:
get-environment:
@ -136,6 +134,7 @@ jobs:
- name: Delivery
uses: ./.github/actions/deb-delivery
with:
module_name: perl-vmware-vsphere
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
stability: ${{ needs.get-environment.outputs.stability }}

View File

@ -14,22 +14,6 @@ on:
type: string
required: true
secrets:
nexus_username:
required: true
nexus_password:
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
artifactory_token:
description: "The artifactory token"
required: true
@ -102,11 +86,8 @@ jobs:
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]
@ -122,6 +103,7 @@ jobs:
- name: Delivery
uses: ./.github/actions/deb-delivery
with:
module_name: plugins
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
stability: ${{ inputs.stability }}
@ -143,12 +125,12 @@ jobs:
- name: Delivery
uses: ./.github/actions/deb-delivery-legacy
with:
module_name: plugins
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 }}
release-tag:
if: ${{ inputs.stability == 'stable' && github.event_name == 'push' }}

View File

@ -235,11 +235,5 @@ jobs:
release: ${{ needs.get-environment.outputs.release }}
stability: ${{ needs.get-environment.outputs.stability }}
secrets:
nexus_username: ${{ secrets.NEXUS_USERNAME }}
nexus_password: ${{ secrets.NEXUS_PASSWORD }}
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 }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
token_download_centreon_com: ${{ secrets.TOKEN_DOWNLOAD_CENTREON_COM }}

View File

@ -36,12 +36,12 @@ contents:
file_info:
mode: 0644
- src: "files/nrpe3.service.rpm"
- src: "files/nrpe3.rpm.service"
dst: "/lib/systemd/system/centreon-nrpe3.service"
packager: rpm
file_info:
mode: 0644
- src: "files/nrpe3.service.deb"
- src: "files/nrpe3.deb.service"
dst: "/lib/systemd/system/centreon-nrpe3.service"
packager: deb
file_info: