diff --git a/.github/actions/deb-delivery-legacy/action.yml b/.github/actions/deb-delivery-legacy/action.yml new file mode 100644 index 000000000..00cba4df8 --- /dev/null +++ b/.github/actions/deb-delivery-legacy/action.yml @@ -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 diff --git a/.github/actions/deb-delivery/action.yml b/.github/actions/deb-delivery/action.yml index 892338fe7..6d57f6f98 100644 --- a/.github/actions/deb-delivery/action.yml +++ b/.github/actions/deb-delivery/action.yml @@ -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 diff --git a/.github/actions/rpm-delivery-legacy/action.yml b/.github/actions/rpm-delivery-legacy/action.yml new file mode 100644 index 000000000..dba196186 --- /dev/null +++ b/.github/actions/rpm-delivery-legacy/action.yml @@ -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 diff --git a/.github/actions/rpm-delivery/action.yml b/.github/actions/rpm-delivery/action.yml index fcddf4e84..99b16e438 100644 --- a/.github/actions/rpm-delivery/action.yml +++ b/.github/actions/rpm-delivery/action.yml @@ -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 diff --git a/.github/workflows/connector-vmware.yml b/.github/workflows/connector-vmware.yml index 03b21bae7..6afd589d3 100644 --- a/.github/workflows/connector-vmware.yml +++ b/.github/workflows/connector-vmware.yml @@ -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 }} diff --git a/.github/workflows/perl-vmware-vsphere.yml b/.github/workflows/perl-vmware-vsphere.yml index c4bc51aae..be2485f30 100644 --- a/.github/workflows/perl-vmware-vsphere.yml +++ b/.github/workflows/perl-vmware-vsphere.yml @@ -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 }} diff --git a/.github/workflows/plugin-delivery.yml b/.github/workflows/plugin-delivery.yml index 66fbc7541..d0a0226d7 100644 --- a/.github/workflows/plugin-delivery.yml +++ b/.github/workflows/plugin-delivery.yml @@ -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 }} diff --git a/.github/workflows/plugin-package.yml b/.github/workflows/plugin-package.yml index 81bade299..9a75f5fe4 100644 --- a/.github/workflows/plugin-package.yml +++ b/.github/workflows/plugin-package.yml @@ -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: diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 850d3c166..6af13d3d1 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -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