chore(ci): move stream connectors to collect repository #157
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: stream-connectors | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- stream-connectors/centreon-certified/** | |
push: | |
branches: | |
- develop | |
- dev-[2-9][0-9].[0-9][0-9].x | |
- master | |
- "[2-9][0-9].[0-9][0-9].x" | |
paths: | |
- stream-connectors/centreon-certified/** | |
jobs: | |
get-version: | |
uses: ./.github/workflows/get-version.yml | |
detect-changes: | |
runs-on: ubuntu-22.04 | |
outputs: | |
connectors: ${{ steps.list-connectors.outputs.connectors }} | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0 | |
id: filter | |
with: | |
base: ${{ github.ref }} | |
list-files: shell | |
filters: | | |
connectors: | |
- stream-connectors/centreon-certified/** | |
- name: transform to directories | |
id: list-connectors | |
run: | | |
folders=() | |
for f in ${{ steps.filter.outputs.connectors_files }}; do | |
DIR_NAME=($(dirname $f)) | |
BASE_NAME=($(basename $DIR_NAME)) | |
echo "Adding $BASE_NAME to folders" | |
folders+=($BASE_NAME) | |
done | |
unique_folders=($(printf "%s\n" "${folders[@]}" | sort -u | tr '\n' ' ')) | |
echo "connectors=$(jq --compact-output --null-input '$ARGS.positional' --args -- ${unique_folders[@]})" >> $GITHUB_OUTPUT | |
shell: bash | |
package: | |
if: ${{ needs.detect-changes.outputs.connectors != '[]' }} | |
needs: [get-version, detect-changes] | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
distrib: [el8, el9, bullseye, bookworm, jammy] | |
connector_path: ${{ fromJson(needs.detect-changes.outputs.connectors) }} | |
include: | |
- distrib: el8 | |
image: packaging-stream-connectors-nfpm-alma8 | |
package_extension: rpm | |
- distrib: el9 | |
image: packaging-stream-connectors-nfpm-alma9 | |
package_extension: rpm | |
- distrib: bullseye | |
image: packaging-stream-connectors-nfpm-bullseye | |
package_extension: deb | |
- distrib: bookworm | |
image: packaging-stream-connectors-nfpm-bookworm | |
package_extension: deb | |
- distrib: jammy | |
image: packaging-stream-connectors-nfpm-jammy | |
package_extension: deb | |
name: package ${{ matrix.distrib }} ${{ matrix.connector_path }} | |
container: | |
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ needs.get-version.outputs.version }} | |
credentials: | |
username: ${{ secrets.DOCKER_REGISTRY_ID }} | |
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }} | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: Replace package and connector name variables | |
run: | | |
package_name="centreon-stream-connector-`basename ${{ matrix.connector_path }}`" | |
sed -i "s/@PACKAGE_NAME@/$package_name/g" ./stream-connectors/packaging/connectors/centreon-stream-connectors.yaml | |
connector_name="`basename ${{ matrix.connector_path }}`" | |
sed -i "s/@CONNECTOR_NAME@/$connector_name/g" ./stream-connectors/packaging/connectors/centreon-stream-connectors.yaml | |
shell: bash | |
- name: Add specific dependencies | |
run: | | |
DEB_DEPENDENCIES="" | |
RPM_DEPENDENCIES="" | |
if [ "${{ matrix.connector_path }}" = "kafka" ]; then | |
DEB_DEPENDENCIES='librdkafka1,"lua-cffi (>= ${MAJOR_VERSION}~)","lua-cffi (<< ${NEXT_MAJOR_VERSION}~)"' | |
RPM_DEPENDENCIES='librdkafka,"lua-cffi >= ${MAJOR_VERSION}","lua-cffi ${NEXT_MAJOR_VERSION}"' | |
elif [ "${{ matrix.connector_path }}" = "pagerduty" ]; then | |
DEB_DEPENDENCIES='"lua-tz (>= ${MAJOR_VERSION}~)","lua-tz (<< ${NEXT_MAJOR_VERSION}~)"' | |
RPM_DEPENDENCIES='"lua-tz >= ${MAJOR_VERSION}","lua-tz ${NEXT_MAJOR_VERSION}"' | |
elif [ "${{ matrix.connector_path }}" = "splunk" ]; then | |
DEB_DEPENDENCIES='"lua-tz (>= ${MAJOR_VERSION}~)","lua-tz (<< ${NEXT_MAJOR_VERSION}~)"' | |
RPM_DEPENDENCIES='"lua-tz >= ${MAJOR_VERSION}","lua-tz ${NEXT_MAJOR_VERSION}"' | |
fi | |
sed -i "s/@RPM_DEPENDENCIES@/$RPM_DEPENDENCIES/g;" ./stream-connectors/packaging/connectors/centreon-stream-connectors.yaml | |
sed -i "s/@DEB_DEPENDENCIES@/$DEB_DEPENDENCIES/g;" ./stream-connectors/packaging/connectors/centreon-stream-connectors.yaml | |
shell: bash | |
- name: Export package version | |
id: package-version | |
run: echo "package_version=`date '+%Y%m%d'`" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Package | |
uses: ./.github/actions/package | |
with: | |
nfpm_file_pattern: "stream-connectors/packaging/connectors/centreon-stream-connectors.yaml" | |
distrib: ${{ matrix.distrib }} | |
major_version: ${{ needs.get-version.outputs.version }} | |
version: ${{ needs.get-version.outputs.version }}.${{ steps.package-version.outputs.package_version }} | |
release: "1" | |
package_extension: ${{ matrix.package_extension }} | |
arch: all | |
commit_hash: ${{ github.sha }} | |
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.connector_path }}-${{ matrix.distrib }} | |
rpm_gpg_key: ${{ secrets.RPM_GPG_SIGNING_KEY }} | |
rpm_gpg_signing_key_id: ${{ secrets.RPM_GPG_SIGNING_KEY_ID }} | |
rpm_gpg_signing_passphrase: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }} | |
stability: ${{ needs.get-version.outputs.stability }} | |
deliver-rpm: | |
if: ${{ contains(fromJson('["unstable", "testing", "stable"]'), needs.get-version.outputs.stability) }} | |
needs: [get-version, detect-changes, package] | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
distrib: [el8, el9] | |
connector_path: ${{ fromJson(needs.detect-changes.outputs.connectors) }} | |
name: deliver ${{ matrix.distrib }} ${{ matrix.connector_path }} | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: Publish RPM packages | |
uses: ./.github/actions/delivery | |
with: | |
module_name: stream-connector-${{ matrix.connector_path }} | |
distrib: ${{ matrix.distrib }} | |
version: ${{ needs.get-version.outputs.version }} | |
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} | |
cache_key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.connector_path }}-${{ matrix.distrib }} | |
stability: ${{ needs.get-version.outputs.stability }} | |
deliver-deb: | |
if: ${{ contains(fromJson('["unstable", "testing", "stable"]'), needs.get-version.outputs.stability) }} | |
needs: [get-version, detect-changes, package] | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
distrib: [bullseye, bookworm, jammy] | |
connector_path: ${{ fromJson(needs.detect-changes.outputs.connectors) }} | |
name: deliver ${{ matrix.distrib }} ${{ matrix.connector_path }} | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: Publish DEB packages | |
uses: ./.github/actions/delivery | |
with: | |
module_name: stream-connector-${{ matrix.connector_path }} | |
distrib: ${{ matrix.distrib }} | |
version: ${{ needs.get-version.outputs.version }} | |
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} | |
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.connector_path }}-${{ matrix.distrib }} | |
stability: ${{ needs.get-version.outputs.stability }} |