Fix link to Grafana article #16913
Workflow file for this run
This file contains hidden or 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: documentation | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| push: | |
| branches: | |
| - staging | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| dependency-scan: | |
| uses: centreon/security-tools/.github/workflows/dependency-analysis.yml@main | |
| get-versions: | |
| needs: [dependency-scan] | |
| runs-on: ubuntu-24.04 | |
| name: Get versions | |
| outputs: | |
| build_environments: ${{ steps.filters.outputs.build_environments }} | |
| build_versions: ${{ steps.filters.outputs.build_versions }} | |
| build_next_version: ${{ steps.filters.outputs.build_next_version }} | |
| build_pp: ${{ steps.filters.outputs.build_pp }} | |
| build_cloud: ${{ steps.filters.outputs.build_cloud }} | |
| build_cxm: ${{ steps.filters.outputs.build_cxm }} | |
| build_logmanagement: ${{ steps.filters.outputs.build_logmanagement }} | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Get changes | |
| uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | |
| id: changes | |
| with: | |
| token: ${{ github.token }} | |
| list-files: 'json' | |
| filters: | | |
| global: | |
| - babel.config.js | |
| - docusaurus.config.js | |
| - package.json | |
| - versions.json | |
| - nextVersion.json | |
| - pnpm-lock.yaml | |
| - 'src/**' | |
| - 'static/**' | |
| - 'i18n/**/(code|footer|navbar).json' | |
| - 'i18n/**/index.js' | |
| cloud: | |
| - 'cloud/**' | |
| - 'i18n/**/docusaurus-plugin-content-docs-cloud/**' | |
| cxm: | |
| - 'cxm/**' | |
| - 'i18n/**/docusaurus-plugin-content-docs-cxm/**' | |
| logmanagement: | |
| - 'logmanagement/**' | |
| - 'i18n/**/docusaurus-plugin-content-docs-logmanagement/**' | |
| pp: | |
| - 'pp/**' | |
| - 'i18n/**/docusaurus-plugin-content-docs-pp/**' | |
| versions: | |
| - 'i18n/**/docusaurus-plugin-content-docs/**' | |
| - 'versioned_docs/**' | |
| - 'versioned_sidebars/**' | |
| - name: Manage versions to build | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| if: ${{ steps.changes.outputs.global == 'false' && steps.changes.outputs.versions_count < 100 }} | |
| with: | |
| script: | | |
| const available_versions = require('./versions.json'); | |
| let build_next_version = require('./nextVersion.json').version; | |
| let build_versions = [...available_versions]; | |
| if (build_versions.includes(build_next_version)) { | |
| build_versions.splice(build_versions.indexOf(build_next_version), 1); | |
| } | |
| let build_pp = '1'; | |
| let build_cloud = '1'; | |
| let build_cxm = '1'; | |
| let build_logmanagement = '1'; | |
| if ('${{ github.event_name }}' === 'pull_request' && ${{ steps.changes.outputs.global }} === false) { | |
| if (${{ steps.changes.outputs.versions }} === false && ${{ steps.changes.outputs.pp }} === false) { | |
| build_pp = '0'; | |
| } | |
| if (${{ steps.changes.outputs.versions }} === false && ${{ steps.changes.outputs.cloud }} === false) { | |
| build_cloud = '0'; | |
| } | |
| if (${{ steps.changes.outputs.versions }} === false && ${{ steps.changes.outputs.cxm }} === false) { | |
| build_cxm = '0'; | |
| } | |
| if (${{ steps.changes.outputs.versions }} === false && ${{ steps.changes.outputs.logmanagement }} === false) { | |
| build_logmanagement = '0'; | |
| } | |
| build_versions = []; | |
| build_next_version = null; | |
| if (${{ steps.changes.outputs.versions }} === true) { | |
| const next_version = require('./nextVersion.json').version; | |
| ${{ steps.changes.outputs.versions_files }}.map((file) => { | |
| [...file.matchAll(/(\d{2}\.(04|10))/g)].map((result) => { | |
| console.log(`Version ${result[1]} updated : ${file}`); | |
| if (next_version === result[1]) { | |
| build_next_version = next_version; | |
| } else if (available_versions.includes(result[1])) { | |
| build_versions.push(result[1]); | |
| } | |
| }); | |
| }); | |
| build_versions = [...new Set(build_versions)].sort().reverse(); // remove duplicates and sort desc | |
| } | |
| if ( | |
| build_versions.length === 0 && | |
| (build_pp === '1' || build_cloud === '1' || build_cxm === '1' || build_logmanagement === '1') | |
| ) { | |
| build_versions.push(available_versions[0]); | |
| } | |
| } | |
| console.log(`Following versions will be built: ${build_versions.join(',')}`); | |
| console.log(`next version will${build_next_version === null ? ' not' : ''} be built`); | |
| console.log(`pp section will${build_pp === '0' ? ' not' : ''} be built`); | |
| console.log(`cloud section will${build_cloud === '0' ? ' not' : ''} be built`); | |
| console.log(`cxm section will${build_cxm === '0' ? ' not' : ''} be built`); | |
| console.log(`logmanagement section will${build_logmanagement === '0' ? ' not' : ''} be built`); | |
| const build_environments = []; | |
| if (build_versions.length) { | |
| build_environments.push('staging'); | |
| } | |
| if (build_next_version !== null && available_versions.includes(build_next_version)) { | |
| build_environments.push('next'); | |
| } | |
| core.exportVariable('build_environments', JSON.stringify(build_environments)); | |
| core.exportVariable('build_versions', build_versions.join(',')); | |
| core.exportVariable('build_next_version', build_next_version); | |
| core.exportVariable('build_pp', build_pp); | |
| core.exportVariable('build_cloud', build_cloud); | |
| core.exportVariable('build_cxm', build_cxm); | |
| core.exportVariable('build_logmanagement', build_logmanagement); | |
| - name: Manage versions to build | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| if: ${{ steps.changes.outputs.global == 'true' || steps.changes.outputs.versions_count >= 100 || (github.ref_name == 'staging' && github.event_name != 'pull_request') }} | |
| with: | |
| script: | | |
| let build_versions = require('./versions.json'); | |
| let build_next_version = require('./nextVersion.json').version; | |
| const build_environments = ['staging']; | |
| if (build_versions.includes(build_next_version)) { | |
| build_environments.push('next'); | |
| build_versions.splice(build_versions.indexOf(build_next_version), 1); | |
| } | |
| core.exportVariable('build_environments', JSON.stringify(build_environments)); | |
| core.exportVariable('build_versions', build_versions.join(',')); | |
| core.exportVariable('build_next_version', require('./nextVersion.json').version); | |
| core.exportVariable('build_pp', '1'); | |
| core.exportVariable('build_cloud', '1'); | |
| core.exportVariable('build_cxm', '1'); | |
| core.exportVariable('build_logmanagement', '1'); | |
| - name: Manage versions to build | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| id: filters | |
| with: | |
| script: | | |
| core.setOutput('build_environments', '${{ env.build_environments }}'); | |
| core.setOutput('build_versions', '${{ env.build_versions }}'); | |
| core.setOutput('build_next_version', '${{ env.build_next_version }}'); | |
| core.setOutput('build_pp', '${{ env.build_pp }}'); | |
| core.setOutput('build_cloud', '${{ env.build_cloud }}'); | |
| core.setOutput('build_cxm', '${{ env.build_cxm }}'); | |
| core.setOutput('build_logmanagement', '${{ env.build_logmanagement }}'); | |
| build: | |
| if: ${{ needs.get-versions.outputs.build_environments != '[]' }} | |
| runs-on: ubuntu-24.04 | |
| needs: [get-versions] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| environment: ${{ fromJson(needs.get-versions.outputs.build_environments) }} | |
| include: | |
| - versions: ${{ needs.get-versions.outputs.build_versions }} | |
| next_version: ${{ needs.get-versions.outputs.build_next_version }} | |
| pp: ${{ needs.get-versions.outputs.build_pp }} | |
| cloud: ${{ needs.get-versions.outputs.build_cloud }} | |
| cxm: ${{ needs.get-versions.outputs.build_cxm }} | |
| logmanagement: ${{ needs.get-versions.outputs.build_logmanagement }} | |
| name: Build ${{ matrix.environment }} | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 2147483647 # full history of a single branch: https://git-scm.com/docs/shallow | |
| - uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 | |
| with: | |
| version: 10 | |
| run_install: false | |
| - name: Set up Node | |
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| cache-dependency-path: pnpm-lock.yaml | |
| - name: Install dependencies | |
| run: | | |
| pnpm install \ | |
| --frozen-lockfile \ | |
| --config.trustPolicy=no-downgrade \ | |
| --config.minimumReleaseAge=2880 \ | |
| --config.blockExoticSubdeps=true | |
| shell: bash | |
| - name: Build documentation | |
| run: pnpm build | |
| env: | |
| NODE_OPTIONS: --max_old_space_size=16000 | |
| BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
| PP: ${{ matrix.pp }} | |
| CLOUD: ${{ matrix.cloud }} | |
| CXM: ${{ matrix.cxm }} | |
| LOGMANAGEMENT: ${{ matrix.logmanagement }} | |
| VERSIONS: ${{ matrix.environment == 'staging' && matrix.versions || matrix.next_version }} | |
| BASE_URL: ${{ github.event_name == 'pull_request' && format('/previews/pr-{0}/{1}', github.event.pull_request.number, matrix.environment) || '' }} | |
| - name: Clear previous docusaurus build & rspack cache from github cache | |
| env: | |
| CACHE_KEY_SUFFIX: "${{ matrix.environment }}-${{ github.head_ref || github.ref_name }}" | |
| run: | | |
| for key in "docusaurus-build-$CACHE_KEY_SUFFIX" "docusaurus-rspack-$CACHE_KEY_SUFFIX"; do | |
| curl \ | |
| -X DELETE \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| https://api.github.com/repos/centreon/centreon-documentation/actions/caches?key=$key | |
| done | |
| shell: bash | |
| - name: Store docusaurus build in cache | |
| uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | |
| with: | |
| path: | | |
| build | |
| key: docusaurus-build-${{ matrix.environment }}-${{ github.head_ref || github.ref_name }} | |
| deploy-preview: | |
| if: ${{ github.event_name == 'pull_request' }} | |
| needs: [get-versions, build] | |
| runs-on: infrastructure | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| environment: ${{ fromJson(needs.get-versions.outputs.build_environments) }} | |
| name: Deploy preview ${{ matrix.environment }} | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Restore build from cache | |
| uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | |
| with: | |
| path: | | |
| build | |
| key: docusaurus-build-${{ matrix.environment }}-${{ github.head_ref || github.ref_name }} | |
| fail-on-cache-miss: true | |
| - name: Setup awscli | |
| run: | | |
| if ! command -v aws >/dev/null 2>&1; then | |
| curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
| sudo unzip -q awscliv2.zip | |
| sudo ./aws/install | |
| fi | |
| shell: bash | |
| - name: Deploy to https://docs-preview-int.centreon.com | |
| run: | | |
| echo "datetime=$(date '+%Y-%m-%d %H:%M %Z')" >> $GITHUB_ENV | |
| export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" \ | |
| $(aws sts assume-role \ | |
| --role-arn ${{ secrets.CLOUDFRONT_ROLE_DOC_PRODUCTION }} \ | |
| --role-session-name InvalidDocCache \ | |
| --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \ | |
| --output text)) | |
| aws s3 sync --delete build s3://centreon-documentation-preview-pr/previews/pr-${{ github.event.pull_request.number }}/${{ matrix.environment }}/ | |
| aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_ID_DOC_PREVIEW }} --paths "/previews/pr-${{ github.event.pull_request.number }}/${{ matrix.environment }}/*" | |
| shell: bash | |
| comment-preview: | |
| needs: [get-versions, deploy-preview] | |
| runs-on: ubuntu-24.04 | |
| name: Add comment for preview | |
| steps: | |
| - name: Prepare environment variables for comment | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| with: | |
| script: | | |
| const preview_urls = ${{ needs.get-versions.outputs.build_environments }}.map((environment) => { | |
| return `:rocket: Deployed preview to https://docs-preview-int.centreon.com/previews/pr-${{ github.event.pull_request.number }}/${environment}/`; | |
| }) | |
| core.exportVariable('datetime', new Date().toUTCString()); | |
| core.exportVariable('preview_urls',preview_urls.join('\n')); | |
| - name: Leave a comment after deployment | |
| uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4 | |
| with: | |
| header: pr-preview | |
| message: "\ | |
| **PR Previews** | |
| :---: | |
| ${{ env.preview_urls }} | |
| at ${{ env.datetime }} | |
| > **_NOTE:_** Previews are deleted after 30 days of inactivity | |
| " | |
| deploy-staging: | |
| if: ${{ github.ref_name == 'staging' && github.event_name != 'pull_request' && contains(fromJson(needs.get-versions.outputs.build_environments), 'staging') }} | |
| needs: [get-versions, build] | |
| runs-on: infrastructure | |
| name: Deploy to staging | |
| environment: | |
| name: staging | |
| url: https://docs-staging.int.centreon.com | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Restore build from cache | |
| uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | |
| with: | |
| path: | | |
| build | |
| key: docusaurus-build-staging-${{ github.head_ref || github.ref_name }} | |
| fail-on-cache-miss: true | |
| - name: Deploy to https://docs-staging.int.centreon.com | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y rsync | |
| # Prepare ssh-key | |
| eval `ssh-agent` | |
| ssh-add - <<< "${{ secrets.INT_SSH_KEY }}" | |
| rsync -e "ssh -o StrictHostKeyChecking=no" -arzvh --delete build/* [email protected]:/var/www/html/ \ | |
| || rsync -e "ssh -o StrictHostKeyChecking=no" -arzvh --delete build/* admin@${{ secrets.DOC_DEV_IP_ADDRESS }}:/var/www/html/ | |
| shell: bash | |
| deploy-next: | |
| if: ${{ github.ref_name == 'staging' && github.event_name != 'pull_request' && contains(fromJson(needs.get-versions.outputs.build_environments), 'next') }} | |
| needs: [get-versions, build] | |
| runs-on: infrastructure | |
| name: Deploy to next | |
| environment: | |
| name: next | |
| url: https://docs-next-int.centreon.com | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Restore build from cache | |
| uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | |
| with: | |
| path: | | |
| build | |
| key: docusaurus-build-next-${{ github.head_ref || github.ref_name }} | |
| fail-on-cache-miss: true | |
| - name: Setup awscli | |
| run: | | |
| if ! command -v aws >/dev/null 2>&1; then | |
| curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
| sudo unzip -q awscliv2.zip | |
| sudo ./aws/install | |
| fi | |
| shell: bash | |
| - name: Deploy to https://docs-next-int.centreon.com | |
| run: | | |
| export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" \ | |
| $(aws sts assume-role \ | |
| --role-arn ${{ secrets.CLOUDFRONT_ROLE_DOC_PRODUCTION }} \ | |
| --role-session-name InvalidDocCache \ | |
| --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \ | |
| --output text)) | |
| aws s3 sync --delete build s3://centreon-documentation-next/ | |
| aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_ID_DOC_NEXT }} --paths "/*" | |
| shell: bash |